/* =========================================================================
   Balbinotti Console — folha de estilos única
   Organização:
     1. Reset básico
     2. Variáveis de tema (cores, fontes, raio) — claro e escuro
     3. Estilos base (body, tipografia)
     4. Utilitários de layout (flex/grid/espaçamento genéricos)
     5. Componentes (botão, input, cartão, tabela, badge, avatar...)
     6. Telas específicas (login, app-shell, chat, admin)
   ========================================================================= */

/* ---------- 1. Reset básico ---------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

table {
  border-collapse: collapse;
}

/* ---------- 2. Variáveis de tema ------------------------------------------
   Paleta Balbinotti (Balbinotti_Cores_RGB):
   night #01232B · sapphire #0E5372 · ocean #0088B2 · sky #8DC3E0
   sunrise #EBEB8C · light #EDEDE2 · neutral #959B95 · graphite #222322
--------------------------------------------------------------------------- */
:root {
  --font-sans: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius-sm: 0.125rem;
  --radius-md: 0.25rem;
  --radius-lg: 0.375rem;

  --brand-night: oklch(0.16 0 0);
  --brand-night-foreground: oklch(0.9431 0.0146 106.68);
  --brand-sapphire: oklch(0.4178 0.0817 234.16);
  --brand-ocean: oklch(0.5859 0.1152 228.78);
  --brand-sky: oklch(0.7899 0.0697 232.24);
  --brand-sunrise: oklch(0.9196 0.1176 108.51);
  --brand-sunrise-foreground: oklch(0.145 0 0);

  --background: oklch(0.9431 0.0146 106.68);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --primary: oklch(0.9196 0.1176 108.51);
  --primary-foreground: oklch(0.145 0 0);
  --secondary: oklch(0.9695 0.0088 106.68);
  --secondary-foreground: oklch(0.145 0 0);
  --muted: oklch(0.9695 0.0088 106.68);
  --muted-foreground: oklch(0.474 0.0087 132.5);
  --accent: oklch(0.9531 0.0451 108.51);
  --accent-foreground: oklch(0.145 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.99 0.003 248);
  --border: oklch(0.8626 0.007 145.51);
  --input: oklch(0.8626 0.007 145.51);
  --ring: oklch(0.9196 0.1176 108.51);

  --sidebar: oklch(0.9695 0.0088 106.68);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-accent: oklch(0.9531 0.0451 108.51);
  --sidebar-accent-foreground: oklch(0.145 0 0);
}

/* Tema escuro: aplique adicionando class="dark" na tag <html> */
.dark {
  --background: oklch(0.1832 0.0311 216.85);
  --foreground: oklch(0.9431 0.0146 106.68);
  --card: oklch(0.2365 0.0412 216.85);
  --card-foreground: oklch(0.9431 0.0146 106.68);
  --secondary: oklch(0.3 0.0509 220);
  --secondary-foreground: oklch(0.9431 0.0146 106.68);
  --muted: oklch(0.3 0.0509 220);
  --muted-foreground: oklch(0.7899 0.0697 232.24);
  --accent: oklch(0.4178 0.0817 234.16);
  --accent-foreground: oklch(0.9431 0.0146 106.68);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.984 0.003 247.858);
  --border: oklch(1 0 0 / 12%);
  --input: oklch(1 0 0 / 16%);

  --sidebar: oklch(0.2365 0.0412 216.85);
  --sidebar-foreground: oklch(0.9431 0.0146 106.68);
  --sidebar-accent: oklch(0.3 0.0509 220);
  --sidebar-accent-foreground: oklch(0.9431 0.0146 106.68);
}

/* ---------- 3. Base -------------------------------------------------------- */
html,
body {
  height: 100%;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.font-mono {
  font-family: var(--font-mono);
}

.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;
}

/* ---------- 4. Layout utilitário ------------------------------------------ */
.icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.icon-sm {
  width: 0.875rem;
  height: 0.875rem;
}

/* ---------- 5. Componentes -------------------------------------------------- */

/* Botão */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.9rem;
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: 500;
  background-color: var(--primary);
  color: var(--primary-foreground);
  white-space: nowrap;
  transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  opacity: 0.9;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.btn-block {
  width: 100%;
}

.btn.btn-icon {
  width: 2.25rem;
  padding: 0;
}

.btn.btn-ghost {
  background-color: transparent;
  color: var(--muted-foreground);
}

.btn.btn-ghost:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.btn.btn-ghost:hover.btn-danger-hover {
  color: var(--destructive);
}

.btn.btn-sm {
  height: 2rem;
  padding: 0 0.65rem;
  font-size: 0.8rem;
}

/* Input */
.input {
  display: block;
  width: 100%;
  height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-lg);
  background-color: var(--card);
  color: var(--foreground);
  font-size: 0.875rem;
}

.input::placeholder {
  color: var(--muted-foreground);
}

.input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.input-search-wrap {
  position: relative;
}

.input-search-wrap .icon {
  position: absolute;
  top: 50%;
  left: 0.65rem;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}

.input-search-wrap .input {
  padding-left: 2rem;
}

/* Cartão */
.card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.125rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--muted);
  color: var(--muted-foreground);
}

.badge.badge-active {
  background-color: var(--brand-sunrise);
  color: var(--brand-sunrise-foreground);
}

/* =========================================================================
   6. Telas específicas
   ========================================================================= */

/* --- Login ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--background);
  padding: 0 1rem;
}

.login-card {
  width: 100%;
  max-width: 24rem;
  padding: 1.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.login-card .logo {
  height: auto;
  width: auto;
}

.login-card h1 {
  margin-top: 1.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.login-card .subtitle {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.login-form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-error {
  font-size: 0.875rem;
  color: var(--destructive);
}

.demo-accounts {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.demo-accounts .label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-foreground);
}

.demo-accounts-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.demo-account-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 0.75rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.demo-account-btn:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.demo-account-btn .email {
  font-family: var(--font-mono);
}

.demo-account-btn .role {
  color: var(--muted-foreground);
}

/* --- App shell (cabeçalho comum a index e admin) --------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--background);
  color: var(--foreground);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  flex-shrink: 0;
  padding: 0 1.25rem;
  background-color: var(--brand-night);
  color: var(--brand-night-foreground);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header .brand .logo {
  height: 60px;
  width: auto;
}

.app-header .brand .tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--brand-sunrise);
}

@media (max-width: 640px) {
  .app-header .brand .tag {
    display: none;
  }
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--brand-night-foreground);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background-color: transparent;
  color: var(--brand-sunrise);
}

.nav-link.active {
  background-color: var(--brand-sunrise);
  color: var(--brand-sunrise-foreground);
  font-weight: 500;
}

.nav-link.active:hover {
  background-color: var(--brand-sunrise);
  color: var(--brand-sunrise-foreground);
}

.session-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid oklch(1 0 0 / 16%);
}

.session-box .who {
  text-align: right;
  line-height: 1.2;
}

.session-box .who .name {
  font-size: 0.875rem;
  font-weight: 500;
}

.session-box .who .level {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brand-sunrise);
}

.logout-btn {
  border-radius: var(--radius-md);
  padding: 0.5rem;
  color: var(--brand-night-foreground);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
  background-color: transparent;
  color: var(--brand-sunrise);
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
}

/* --- Chat (index) ------------------------------------------------------- */
.chat-layout {
  display: flex;
  height: 100%;
  min-height: 0;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  width: 18rem;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background-color: var(--sidebar);
}

.chat-sidebar-top {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-sidebar-top .btn {
  justify-content: flex-start;
}

.conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.conversation-empty {
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.conversation-item {
  display: flex;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  border-left: 2px solid transparent;
  transition: background-color 0.15s ease;
}

.conversation-item:hover {
  background-color: color-mix(in oklab, var(--sidebar-accent) 60%, transparent);
}

.conversation-item.active {
  border-left-color: var(--brand-sunrise);
  background-color: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

.conversation-item .select-btn {
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}

.conversation-item .title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
}

.conversation-item .preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.conversation-item .delete-btn {
  border-radius: var(--radius-md);
  padding: 0.25rem;
  color: var(--muted-foreground);
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.conversation-item:hover .delete-btn {
  opacity: 1;
}

.conversation-item .delete-btn:hover {
  color: var(--destructive);
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.chat-scroll-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chat-empty-state {
  padding-top: 4rem;
  text-align: center;
}

.chat-empty-state img {
  margin: 0 auto;
  height: 3.5rem;
  width: 3.5rem;
  border-radius: var(--radius-lg);
}

.chat-empty-state h1 {
  margin-top: 1.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.chat-empty-state p {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.chat-message-row {
  display: flex;
  gap: 0.75rem;
}

.chat-message-row.from-user {
  justify-content: flex-end;
}

.chat-avatar {
  margin-top: 0.125rem;
  height: 1.75rem;
  width: 1.75rem;
  flex-shrink: 0;
  border-radius: var(--radius-md);
}

.chat-avatar.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

.chat-bubble {
  max-width: 80%;
  white-space: pre-wrap;
  font-size: 0.875rem;
  line-height: 1.6;
}

.chat-bubble.from-user {
  border-radius: var(--radius-lg);
  background-color: var(--brand-night);
  color: var(--brand-night-foreground);
  padding: 0.625rem 1rem;
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.ai-thinking-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 2.25rem;
}

.ai-thinking-avatar img {
  position: relative;
  z-index: 1;
  width: 1.65rem;
  height: 1.65rem;
  object-fit: contain;
  animation: ai-logo-breathe 1.8s ease-in-out infinite;
}

.ai-thinking-ring {
  position: absolute;
  inset: 0;
  border: 2px solid color-mix(in oklab, var(--brand-sunrise) 35%, transparent);
  border-top-color: var(--brand-sunrise);
  border-radius: 50%;
  animation: ai-ring-spin 1s linear infinite;
}

.ai-thinking-label {
  min-width: 10rem;
  transition: opacity 0.2s ease;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.typing-dots i {
  width: 0.28rem;
  height: 0.28rem;
  border-radius: 50%;
  background: currentColor;
  animation: typing-dot 1.1s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

.chat-bubble.is-revealing::after {
  content: "";
  display: inline-block;
  width: 0.12rem;
  height: 1.05em;
  margin-left: 0.18rem;
  vertical-align: -0.12em;
  background: var(--brand-sunrise);
  animation: typing-caret 0.75s step-end infinite;
}

@keyframes ai-ring-spin { to { transform: rotate(360deg); } }
@keyframes ai-logo-breathe { 50% { transform: scale(0.88); opacity: 0.72; } }
@keyframes typing-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-0.2rem); opacity: 1; } }
@keyframes typing-caret { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .ai-thinking-avatar img,
  .ai-thinking-ring,
  .typing-dots i,
  .chat-bubble.is-revealing::after {
    animation: none;
  }
}

.chat-composer {
  border-top: 1px solid var(--border);
  background-color: var(--card);
  padding: .7rem 1.5rem 1rem;
}

.composer-shell{position:relative;max-width:48rem;margin:0 auto;border:1px solid var(--border);border-radius:1rem;background:var(--background);box-shadow:0 2px 12px rgb(0 0 0/.05);padding:.45rem .5rem .5rem;transition:border-color .15s,box-shadow .15s}.composer-shell:focus-within{border-color:#aaa68d;box-shadow:0 3px 16px rgb(0 0 0/.07)}
.agent-picker-wrap{position:relative;display:flex;align-items:center;width:max-content;max-width:100%;gap:.25rem;margin:0 0 .15rem}.agent-picker-wrap select{appearance:none;border:0;background:transparent;color:var(--muted-foreground);font:600 .7rem var(--font-sans);height:1.65rem;max-width:18rem;padding:.15rem 1.3rem .15rem .45rem;cursor:pointer;background-image:linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);background-position:calc(100% - 9px) 53%,calc(100% - 5px) 53%;background-size:4px 4px,4px 4px;background-repeat:no-repeat}.agent-picker-wrap select:hover{color:var(--foreground);background-color:var(--muted);border-radius:.4rem}.agent-picker-wrap select:focus{outline:none}.agent-picker-wrap select:disabled{opacity:.65;cursor:default}
.agent-specifications{position:relative}.agent-specifications summary{display:grid;place-items:center;width:1.25rem;height:1.25rem;border:1px solid var(--border);border-radius:50%;list-style:none;cursor:pointer;color:var(--muted-foreground);font:600 .66rem Georgia,serif}.agent-specifications summary::-webkit-details-marker{display:none}.agent-specifications summary:hover{color:var(--foreground);background:var(--muted)}.agent-specifications>div{position:absolute;left:0;bottom:calc(100% + .55rem);z-index:20;width:18rem;padding:.8rem;background:var(--background);border:1px solid var(--border);border-radius:.7rem;box-shadow:0 10px 30px rgb(0 0 0/.12)}.agent-specifications dl{display:grid;gap:.55rem;margin:0}.agent-specifications dl div{display:grid;gap:.1rem}.agent-specifications dt{font-size:.6rem;text-transform:uppercase;letter-spacing:.07em;color:var(--muted-foreground)}.agent-specifications dd{margin:0;font-size:.75rem;line-height:1.35;color:var(--foreground)}
.chat-composer-inner{display:flex;align-items:center;gap:.35rem}.chat-composer-inner input{flex:1;min-width:0;border:0;background:transparent;color:var(--foreground);font:inherit;padding:.55rem .45rem}.chat-composer-inner input:focus{outline:none}.composer-send{display:grid;place-items:center;flex:0 0 2rem;width:2rem;height:2rem;border:0;border-radius:.55rem;background:var(--brand-sunrise);color:var(--brand-sunrise-foreground);cursor:pointer}.composer-send:disabled{opacity:.35;cursor:not-allowed}.composer-send .icon{width:1rem;height:1rem}.fieldset-help{font-size:.68rem;color:var(--muted-foreground);margin:0 0 .65rem}@media(max-width:600px){.chat-composer{padding:.55rem}.agent-picker-wrap select{max-width:14rem}.agent-specifications>div{left:-10rem;width:16rem}}

/* --- Admin ---------------------------------------------------------------- */
.admin-scroll {
  height: 100%;
  overflow-y: auto;
}

.admin-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.admin-title h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.admin-title p {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.admin-panel {
  padding: 1.25rem;
}

.admin-panel h2 {
  font-size: 0.875rem;
  font-weight: 600;
}
.admin-agents-entry{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.25rem 0 1rem;border-bottom:1px solid var(--border)}.admin-agents-entry h2{font-size:.875rem;font-weight:600;margin:0}.admin-agents-entry p{font-size:.75rem;color:var(--muted-foreground);margin:.2rem 0 0}.admin-agents-entry .btn{white-space:nowrap}@media(max-width:700px){.admin-agents-entry{align-items:flex-start}.admin-agents-entry p{max-width:16rem}}

.add-user-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .add-user-form {
    grid-template-columns: 1fr 1fr 180px auto;
  }
}

.users-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.users-panel-head h2 {
  font-size: 0.875rem;
  font-weight: 600;
}

.users-panel-head .count {
  color: var(--muted-foreground);
  font-weight: 400;
}

.users-search {
  width: 100%;
  max-width: 20rem;
}

.table-wrap {
  overflow-x: auto;
}

.users-table {
  width: 100%;
  font-size: 0.875rem;
}

.users-table thead tr {
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted-foreground);
}

.users-table th {
  padding: 0.75rem 1rem;
  font-weight: 500;
}

.users-table td {
  padding: 0.75rem 1rem;
}

.users-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.users-table tbody tr:last-child {
  border-bottom: none;
}

.users-table .name-cell {
  font-weight: 500;
}

.users-table .email-cell {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.users-table .role-cell {
  color: var(--muted-foreground);
}

.users-table .actions-cell {
  text-align: right;
}

.users-table .empty-row td {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
}

.trace-filters { display:flex; flex-wrap:wrap; gap:.5rem; align-items:center; }
.trace-filters .input { width:auto; min-width:9rem; }
.trace-summary { margin:1rem 0; padding:.8rem 1rem; border-radius:var(--radius-md); background:var(--muted); color:var(--muted-foreground); }
.trace-row { cursor:pointer; }
.trace-row:hover { background:var(--muted); }
.trace-detail { margin-top:1rem; padding:1rem; border:1px solid var(--border); border-radius:var(--radius-lg); }
.trace-detail-head { display:flex; align-items:center; justify-content:space-between; }
.trace-steps { display:grid; gap:.75rem; margin-top:1rem; }
.trace-steps article { padding:.85rem; border-left:3px solid var(--brand-sunrise); background:var(--muted); border-radius:var(--radius-md); }
.trace-steps article > div { display:flex; justify-content:space-between; gap:1rem; }
.trace-steps article span { color:var(--muted-foreground); font-size:.8rem; }
.trace-steps pre { max-height:18rem; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; }

/* --- Base de conhecimento / editor tipo documento ----------------------- */
[hidden],.admin-only[hidden]{display:none!important}
.knowledge-main{height:calc(100vh - 4rem);display:grid;grid-template-columns:22rem 1fr;background:linear-gradient(135deg,#f3f1ea 0%,#ecebe4 100%)}
.knowledge-sidebar{background:color-mix(in srgb,var(--background) 96%,#f6f1d8);border-right:1px solid var(--border);padding:1.4rem;overflow:auto;box-shadow:8px 0 30px rgb(0 0 0/.025);z-index:2}
.knowledge-sidebar-head{display:flex;justify-content:space-between;gap:1rem;align-items:start;margin-bottom:1rem}.knowledge-sidebar-head h1{font-size:1.1rem}.knowledge-sidebar-head p,.knowledge-loading{font-size:.8rem;color:var(--muted-foreground)}
.knowledge-eyebrow{font:600 .62rem/1 var(--font-mono);letter-spacing:.15em;text-transform:uppercase;color:#8a7426}.knowledge-sidebar-head h1{font-size:1.45rem;margin:.35rem 0 .2rem}.knowledge-primary-actions{display:grid;grid-template-columns:1fr 1fr;gap:.5rem;margin:1.1rem 0}.knowledge-search-wrap{position:relative}.knowledge-search-wrap>span{position:absolute;left:.8rem;top:.55rem;color:var(--muted-foreground);z-index:1}.knowledge-search-wrap .input{padding-left:2rem;background:var(--muted)}.knowledge-list-label{display:flex;justify-content:space-between;margin:1.2rem .25rem .5rem;font:600 .65rem/1 var(--font-mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted-foreground)}
.refresh-documents{width:100%;border:0;background:transparent;color:var(--muted-foreground);padding:.55rem;margin-bottom:.65rem;cursor:pointer;border-radius:.45rem;font-size:.75rem}.refresh-documents:hover{background:var(--muted);color:var(--foreground)}.refresh-documents span{font-size:1rem;margin-right:.25rem}
.document-list{display:grid;gap:.35rem}.document-item{border:1px solid transparent;background:transparent;text-align:left;padding:.7rem;border-radius:.7rem;cursor:pointer;color:inherit;display:grid;grid-template-columns:2.1rem 1fr .45rem;gap:.65rem;align-items:center}.document-item:hover{background:var(--muted)}.document-item.active{background:#fff;border-color:#e5dda9;box-shadow:0 3px 12px rgb(67 55 7/.07)}.document-item-icon{width:2.1rem;height:2.5rem;display:grid;place-items:center;border-radius:.3rem;background:#f3edc5;color:#66551c;font:700 .8rem Georgia,serif}.document-item-copy{min-width:0}.document-item-copy strong,.document-item-copy small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.document-item-copy strong{font-size:.82rem}.document-item-copy small{font-size:.68rem;color:var(--muted-foreground);margin-top:.25rem}.document-item-status{width:.42rem;height:.42rem;border-radius:50%;background:#b9b9b9}.document-item-status.confirmado{background:#3ca76a}.document-item-status.rascunho{background:#d5a525}.knowledge-skeleton{height:3.8rem;border-radius:.7rem;background:linear-gradient(90deg,var(--muted),#fff,var(--muted));background-size:200% 100%;animation:knowledge-shimmer 1.3s infinite}@keyframes knowledge-shimmer{to{background-position:-200% 0}}
.document-folder{margin:.25rem 0}.document-folder>summary{list-style:none;display:grid;grid-template-columns:1rem 1fr auto;align-items:center;gap:.35rem;padding:.45rem .55rem;cursor:pointer;border-radius:.45rem}.document-folder>summary:hover{background:var(--muted)}.document-folder>summary::-webkit-details-marker{display:none}.document-folder>summary strong{font-size:.72rem;text-transform:capitalize}.document-folder>summary small{font-size:.65rem;color:var(--muted-foreground)}.document-folder .folder-icon{font-size:.65rem;transition:transform .15s}.document-folder[open] .folder-icon{transform:rotate(90deg)}.folder-documents{display:grid;gap:.25rem;margin-left:.45rem;padding-left:.45rem;border-left:1px solid var(--border)}
.knowledge-workspace{overflow:auto;padding:1.75rem 2.5rem 4rem}.knowledge-empty{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--muted-foreground);text-align:center}.knowledge-empty-icon{width:4.5rem;height:5.5rem;border:1px solid #d5cfb8;background:#fff;display:grid;place-items:center;font:italic 1.4rem Georgia,serif;box-shadow:6px 7px 0 #ded8c5;margin-bottom:1.5rem}.knowledge-empty h2{font-size:1.2rem;color:var(--foreground)}.knowledge-empty p{max-width:25rem;margin-top:.4rem;font-size:.85rem}
.knowledge-toolbar{max-width:58rem;margin:0 auto .8rem;display:flex;justify-content:space-between;align-items:center;position:static;padding:.65rem .8rem;background:#f3f1ea;border-radius:.65rem;box-shadow:0 3px 14px rgb(0 0 0/.05)}.knowledge-actions{display:flex;gap:.5rem}.document-status-wrap{display:flex;align-items:center;gap:.7rem}.document-status-wrap #save-state{font-size:.7rem;color:var(--muted-foreground)}.status-confirmado{background:#e4f5ea;color:#267746}.status-rascunho{background:#fff4ce;color:#846816}
.knowledge-editor:not(.is-editing) .word-title,.knowledge-editor:not(.is-editing) .word-summary{pointer-events:none;cursor:default}
.edit-mode-label{font:700 .58rem var(--font-mono);letter-spacing:.1em;text-transform:uppercase;padding:.3rem .5rem;border-radius:1rem;background:#fff1a8;color:#6e5900}.knowledge-editor.is-editing .word-page{outline:2px solid #e3d24e;outline-offset:-2px}.knowledge-editor.has-unsaved-changes .word-page{box-shadow:0 6px 28px rgb(173 135 0/.2)}.knowledge-editor.is-editing .knowledge-block.is-dirty{border-top-color:#d5b900}.knowledge-editor.is-editing .knowledge-block.is-dirty::after{content:"Alterações não salvas";position:absolute;right:0;top:.45rem;font:600 .56rem var(--font-mono);letter-spacing:.06em;text-transform:uppercase;color:#8a7000}.block-save.is-saving,#save-document.is-saving{display:inline-flex;align-items:center;justify-content:center;gap:.45rem}.block-save.is-saving::before,#save-document.is-saving::before{content:"";width:.75rem;height:.75rem;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:knowledge-save-spin .65s linear infinite}.block-save.is-saved,#save-document.is-saved{background:#e5f5e9!important;border-color:#75b886!important;color:#267746!important;animation:knowledge-save-confirm .32s ease-out}.block-save.is-saved::before,#save-document.is-saved::before{content:"✓";font-weight:900;margin-right:.35rem}@keyframes knowledge-save-spin{to{transform:rotate(360deg)}}@keyframes knowledge-save-confirm{0%{transform:scale(.94)}65%{transform:scale(1.04)}100%{transform:scale(1)}}
.word-page{max-width:58rem;min-height:72rem;margin:0 auto;background:#fff;color:#202124;box-shadow:0 6px 28px rgb(0 0 0/.11);padding:3.5rem 4.5rem;border-top:4px solid #e3d24e}.word-page-kicker{display:flex;justify-content:space-between;font:600 .62rem/1 var(--font-mono);letter-spacing:.12em;color:#8a8170;margin-bottom:1.4rem}.word-title,.word-summary{display:block;width:100%;border:0;outline:0;background:transparent;color:inherit}.word-title{font:700 2.25rem/1.15 Georgia,var(--font-sans);margin-bottom:.9rem}.word-title::placeholder{color:#aaa}.word-summary{font:1rem/1.6 var(--font-sans);color:#5f6368;resize:vertical;border-left:3px solid #e3d24e;padding-left:1rem}
.doc-metadata{margin:2rem 0;padding:1rem;background:#f7f8fa;border:1px solid #e1e4e8;border-radius:.5rem}.doc-metadata summary{cursor:pointer;font-weight:600}.metadata-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin-top:1rem}.metadata-grid label{font-size:.72rem;color:#5f6368}.metadata-grid .input{margin-top:.3rem;background:#fff}
.suggestion-panel{margin:2rem 0;padding:1.1rem;border:1px solid #e4dba3;background:#fffcf0;border-radius:.65rem}.suggestion-panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:.8rem}.suggestion-panel-head span:first-child{font:600 .58rem var(--font-mono);letter-spacing:.12em;color:#8a7426}.suggestion-panel-head h2{font-size:1rem;margin-top:.2rem}.suggestion-list{display:grid;gap:.65rem}.suggestion-card{background:#fff;border:1px solid #e8e2c7;border-left:3px solid #d4b934;border-radius:.4rem;padding:.8rem}.suggestion-card.aprovada{border-left-color:#3ca76a;opacity:.72}.suggestion-card.rejeitada{border-left-color:#ad6464;opacity:.62}.suggestion-meta{display:flex;justify-content:space-between;font:600 .58rem var(--font-mono);text-transform:uppercase;color:#81775c}.suggestion-card p{font-size:.85rem;line-height:1.5;margin:.55rem 0}.suggestion-card small{display:block;color:var(--muted-foreground);font-size:.72rem}.suggestion-actions{display:flex;gap:.45rem;margin-top:.75rem}.suggestion-empty{font-size:.78rem;color:var(--muted-foreground)}
.block-list{display:grid;gap:2rem;margin-top:2.5rem}.knowledge-block{position:relative;border-top:1px solid #e1e4e8;padding-top:1.4rem}.block-number{position:absolute;left:-3rem;top:1.9rem;font:600 .65rem var(--font-mono);color:#aaa}.knowledge-block header span{font-size:.65rem;text-transform:uppercase;letter-spacing:.12em;color:#8a7426}.knowledge-block header h2{font:700 1.35rem Georgia,serif;margin:.35rem 0 .9rem}.block-reader{line-height:1.75;color:#383838}
.knowledge-block.source-highlight{animation:source-highlight 3.5s ease-out}@keyframes source-highlight{0%,35%{background:#fff3a8;box-shadow:0 0 0 1rem #fff3a8}100%{background:transparent;box-shadow:0 0 0 1rem transparent}}
.block-head,.block-foot,.editor-ribbon{display:flex;gap:.5rem;align-items:center}.block-title{flex:1;font-weight:600}.block-type,.block-status{width:auto}.editor-ribbon{margin-top:.6rem;padding:.35rem .55rem;background:#f5f3ed;border:1px solid #dedbd1;border-bottom:0;border-radius:.4rem .4rem 0 0}.editor-ribbon>span{font:600 .55rem var(--font-mono);letter-spacing:.12em;color:#888;margin-right:.4rem}.editor-ribbon button{border:0;background:transparent;padding:.35rem .55rem;cursor:pointer}.editor-ribbon button:hover{background:#fff}.block-content{width:100%;min-height:11rem;border:1px solid #dedbd1;border-radius:0 0 .4rem .4rem;padding:1.1rem;font:1rem/1.7 Georgia,serif;resize:vertical;outline:0}.block-content:focus{border-color:#c8b83e;box-shadow:0 0 0 2px rgb(227 210 78/.15)}.block-foot{margin-top:.65rem;flex-wrap:wrap}.block-keywords{flex:1;min-width:12rem}.block-check{font-size:.72rem;color:#666}.empty-add-block{width:100%;padding:1.5rem;border:1px dashed #cfc8ad;background:#faf9f4;color:#746824;border-radius:.5rem;cursor:pointer}.empty-add-block:hover{background:#f5f0d8}
.knowledge-insert-panel{position:fixed;z-index:12;top:5rem;right:1rem;bottom:1rem;width:19rem;overflow:auto;background:var(--background);border:1px solid var(--border);border-radius:.8rem;box-shadow:0 12px 40px rgb(0 0 0/.14);padding:1rem}.insert-panel-head{display:flex;align-items:flex-start;justify-content:space-between;padding-bottom:.8rem;border-bottom:1px solid var(--border)}.insert-panel-head span{font:600 .56rem var(--font-mono);letter-spacing:.12em;color:#8a7426}.insert-panel-head h2{font-size:1rem;margin-top:.25rem}.insert-panel-head button{border:0;background:transparent;font-size:1.25rem;color:var(--muted-foreground);cursor:pointer}.knowledge-insert-panel section{padding:1rem 0;border-bottom:1px solid var(--border)}.knowledge-insert-panel section:last-child{border-bottom:0}.knowledge-insert-panel h3{font-size:.78rem}.knowledge-insert-panel section>p{font-size:.68rem;line-height:1.45;color:var(--muted-foreground);margin:.25rem 0 .7rem}.knowledge-insert-panel label{display:block;font-size:.67rem;color:var(--muted-foreground);margin-bottom:.65rem}.knowledge-insert-panel label .input{margin-top:.3rem}.document-link-list{display:grid;gap:.25rem;max-height:17rem;overflow:auto;margin-top:.55rem}.document-link-list button{display:flex;flex-direction:column;gap:.12rem;border:0;background:transparent;text-align:left;padding:.55rem;border-radius:.45rem;cursor:pointer;color:var(--foreground)}.document-link-list button:hover{background:var(--muted)}.document-link-list button span{font-size:.72rem;line-height:1.25}.document-link-list button small{font-size:.6rem;color:var(--muted-foreground);text-transform:capitalize}.insert-empty{font-size:.7rem;color:var(--muted-foreground);padding:.5rem}.image-upload-button{display:block;border:1px dashed #b7aa5b;border-radius:.5rem;padding:.75rem;text-align:center;color:#66551c!important;background:#fffdf2;cursor:pointer}.image-upload-button:hover{background:#fff8ce}.image-upload-button input{display:none}.insert-divider{display:flex;align-items:center;gap:.5rem;margin:.7rem 0;color:var(--muted-foreground);font-size:.6rem}.insert-divider::before,.insert-divider::after{content:"";height:1px;flex:1;background:var(--border)}.knowledge-insert-panel #insert-image-url{width:100%;margin-top:.45rem}.image-upload-status{font-size:.67rem;margin-top:.55rem;color:var(--muted-foreground)}.markdown-image{margin:1.25rem 0}.markdown-image img{display:block;max-width:100%;height:auto;border-radius:.55rem;border:1px solid var(--border)}.markdown-image figcaption{font-size:.7rem;color:var(--muted-foreground);margin-top:.35rem}.markdown-image figcaption:empty{display:none}@media(min-width:1450px){.knowledge-workspace.has-insert-panel #knowledge-editor{padding-right:19.5rem}.knowledge-workspace.has-insert-panel .knowledge-toolbar,.knowledge-workspace.has-insert-panel .word-page{max-width:54rem}}@media(max-width:700px){.knowledge-insert-panel{top:auto;left:.5rem;right:.5rem;bottom:.5rem;width:auto;max-height:70vh}.editor-ribbon{overflow-x:auto}.editor-ribbon button{white-space:nowrap}}
.knowledge-toast{position:fixed;left:50%;top:auto;bottom:max(1rem,env(safe-area-inset-bottom));z-index:30;width:min(28rem,calc(100vw - 2rem));transform:translateX(-50%);padding:.85rem 1rem;border-radius:.6rem;background:#173d29;color:#fff;box-shadow:0 8px 28px rgb(0 0 0/.2);font-size:.82rem;text-align:center;animation:knowledge-toast-in .22s ease-out}.knowledge-toast.error{background:#8a2929}@keyframes knowledge-toast-in{from{opacity:0;transform:translate(-50%,.75rem)}to{opacity:1;transform:translate(-50%,0)}}

/* Links internos da biblioteca — identidade Balbinotti */
.block-reader a{font-weight:650;text-decoration-thickness:1px;text-underline-offset:.18em}
.block-reader .knowledge-document-link{color:inherit;text-decoration-line:underline;text-decoration-color:#e7df2e;text-decoration-thickness:3px;text-underline-offset:.2em;transition:background .15s ease,text-decoration-color .15s ease}
.block-reader .knowledge-document-link:hover,.block-reader .knowledge-document-link:focus-visible{background:linear-gradient(transparent 62%,rgb(238 233 63/.42) 62%);text-decoration-color:#b9ae16;outline:none}
.block-reader .knowledge-document-link:active{background:linear-gradient(transparent 58%,rgb(238 233 63/.7) 58%)}
.block-reader .markdown-external-link{color:#66591a;text-decoration-color:#c6b82c}

.document-link-list{max-height:none}
.document-link-list .document-link-option{display:grid;grid-template-columns:1.75rem minmax(0,1fr) auto;align-items:center;gap:.55rem;padding:.62rem;border:1px solid transparent;border-radius:.5rem}
.document-link-list .document-link-option:hover,.document-link-list .document-link-option:focus-visible{background:#fffdf0;border-color:#d6c94d;outline:none}
.document-link-list .document-link-option.is-selected{background:#eee93f;border-color:#b8ae27;box-shadow:0 4px 14px rgb(68 61 8/.16)}
.document-link-option-mark{display:grid;place-items:center;width:1.65rem;height:1.65rem;border-radius:.3rem;background:#111;color:#eee93f;font:700 .7rem var(--font-sans)}
.document-link-option-copy{display:flex;min-width:0;flex-direction:column;gap:.12rem}
.document-link-option-copy strong{overflow:hidden;text-overflow:ellipsis;font-size:.72rem;line-height:1.25;white-space:nowrap}
.document-link-option-copy small{font-size:.59rem;color:var(--muted-foreground);text-transform:capitalize}
.document-link-option-arrow{color:#8a7426;font-size:.78rem}
.knowledge-confirm{position:fixed;inset:0;margin:auto;width:min(26rem,calc(100vw - 2rem));border:0;border-radius:.8rem;padding:0;box-shadow:0 18px 60px rgb(0 0 0/.28)}.knowledge-confirm::backdrop{background:rgb(22 22 18/.5);backdrop-filter:blur(3px)}.knowledge-confirm form{padding:1.5rem}.knowledge-confirm form>span{font:600 .58rem var(--font-mono);letter-spacing:.14em;color:#8a7426}.knowledge-confirm h2{font-size:1.15rem;margin:.4rem 0}.knowledge-confirm p{font-size:.82rem;color:var(--muted-foreground);line-height:1.5}.knowledge-confirm form>div{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1.25rem}
.message-sources{margin-top:.7rem;border-top:1px solid var(--border);padding-top:.45rem;font-size:.68rem}.message-sources summary{cursor:pointer;color:var(--muted-foreground);user-select:none}.message-sources summary>span{display:inline-grid;place-items:center;min-width:1rem;height:1rem;margin-left:.25rem;border-radius:1rem;background:var(--muted);font-size:.56rem}.message-sources>.message-source-groups{display:grid;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));gap:.35rem;max-height:10rem;overflow:auto;margin-top:.4rem;padding-right:.15rem}.message-source-group{min-width:0;padding:.42rem .5rem;border:1px solid var(--border);border-radius:.45rem;background:var(--background)}.message-source-group header{display:flex;align-items:center;justify-content:space-between;gap:.4rem;padding-bottom:.28rem;border-bottom:1px solid color-mix(in srgb,var(--border) 75%,transparent)}.message-source-group header>a{min-width:0;overflow:hidden;color:#007da8;font-size:.63rem;font-weight:700;text-decoration-color:#dfc900;text-decoration-thickness:1px;text-underline-offset:3px;text-overflow:ellipsis;white-space:nowrap}.message-source-group header>span{flex:0 0 auto;color:var(--muted-foreground);font-size:.5rem}.message-source-group>div{display:grid;gap:.08rem;padding-top:.22rem}.message-source-section{display:flex;min-width:0;align-items:center;justify-content:space-between;gap:.35rem;padding:.18rem .1rem;border-radius:.25rem;color:var(--foreground);font-size:.57rem;text-decoration:none}.message-source-section>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.message-source-section>b{flex:0 0 auto;color:#8a761b;font-size:.58rem}.message-source-section:hover{background:#fffbea;color:#006f96}
@media(max-width:800px){.knowledge-main{grid-template-columns:1fr;height:auto}.knowledge-sidebar{border-right:0;border-bottom:1px solid var(--border);max-height:20rem}.knowledge-workspace{padding:.5rem}.word-page{padding:1.5rem;min-height:40rem}.metadata-grid{grid-template-columns:1fr}}

/* --- Administração de agentes ------------------------------------------ */
.agents-main{height:calc(100vh - 4rem);display:grid;grid-template-columns:22rem 1fr;background:var(--muted)}.agents-library{padding:1.4rem;background:var(--background);border-right:1px solid var(--border);overflow:auto}.agents-head{display:flex;justify-content:space-between;align-items:center}.agents-head span{font:600 .6rem var(--font-mono);letter-spacing:.12em;color:#8a7426}.agents-head h1{font-size:1.45rem;margin-top:.3rem}.agents-library>p{font-size:.75rem;color:var(--muted-foreground);margin:.5rem 0 1.2rem}.agents-list{display:grid;gap:.5rem}.agent-card{display:grid;grid-template-columns:.35rem 1fr;gap:.7rem;text-align:left;border:1px solid transparent;background:transparent;border-radius:.65rem;padding:.75rem;cursor:pointer;color:inherit}.agent-card>span{background:var(--agent);border-radius:1rem}.agent-card strong,.agent-card small,.agent-card p{display:block}.agent-card small{font-size:.65rem;color:var(--muted-foreground);margin:.2rem 0}.agent-card p{font-size:.72rem;color:var(--muted-foreground);line-height:1.35}.agent-card:hover,.agent-card.active{background:#fff;border-color:var(--border);box-shadow:0 3px 12px rgb(0 0 0/.05)}.agent-editor{overflow:auto;padding:2rem}.agent-form{max-width:58rem;margin:0 auto;background:var(--background);border:1px solid var(--border);border-radius:.8rem;padding:1.5rem}.agent-form-top{display:flex;justify-content:space-between;align-items:center;padding-bottom:1.2rem;border-bottom:1px solid var(--border)}.agent-form-top h1{font-size:1.35rem;margin-top:.4rem}.agent-form-top>div:last-child{display:flex;gap:.5rem}.agent-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-top:1.2rem}.agent-form-grid label{font-size:.72rem;color:var(--muted-foreground)}.agent-form-grid label>.input{margin-top:.35rem}.agent-form-grid .span-2{grid-column:1/-1}.agent-form-grid textarea.input{height:auto;padding:.7rem}.agent-form-grid fieldset{border:1px solid var(--border);border-radius:.55rem;padding:.9rem}.agent-form-grid legend{font-size:.72rem;padding:0 .35rem}.agent-collections{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem}.agent-collections label{display:flex;gap:.6rem;padding:.65rem;background:var(--muted);border-radius:.4rem}.agent-collections strong,.agent-collections small{display:block}.agent-collections small{font-size:.65rem;margin-top:.15rem}.agent-instructions{width:100%;margin-top:.35rem;padding:1rem;border:1px solid var(--border);border-radius:.5rem;font: .85rem/1.55 var(--font-mono);resize:vertical}.agent-feedback{margin-top:1rem;padding:.75rem;border-radius:.45rem;font-size:.78rem}.agent-feedback.success{background:#e4f5ea;color:#267746}.agent-feedback.error{background:#fee8e8;color:#922}.agent-form input[type=color]{padding:.2rem;height:2.5rem}@media(max-width:850px){.agents-main{grid-template-columns:1fr;height:auto}.agents-library{max-height:22rem}.agent-editor{padding:.75rem}.agent-form-grid{grid-template-columns:1fr}.agent-form-grid .span-2{grid-column:auto}.agent-collections{grid-template-columns:1fr}}

/* =========================================================================
   Markdown nas respostas da IA
   ========================================================================= */

/* A mensagem do assistente usa HTML estruturado; preserve quebra manual só no usuário. */
.chat-message-row:not(.from-user) .chat-bubble {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 2.5rem);
  white-space: normal;
}

.chat-bubble.from-user {
  white-space: pre-wrap;
}

.markdown-body {
  font-size: 0.9375rem;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body p {
  margin: 0.85rem 0;
}

.markdown-spacer {
  display: block;
  width: 100%;
  pointer-events: none;
}

.markdown-spacer-1 { height: 0.65rem; }
.markdown-spacer-2 { height: 1.25rem; }
.markdown-spacer-3 { height: 1.9rem; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.5rem 0 0.65rem;
  color: var(--foreground);
  line-height: 1.28;
  font-weight: 650;
}

.markdown-body h1 {
  font-size: 1.45rem;
}

.markdown-body h2 {
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.25rem;
}

.markdown-body h3 {
  font-size: 1.075rem;
}

.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-size: 0.95rem;
}

.markdown-body strong {
  font-weight: 700;
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  color: var(--muted-foreground);
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.9rem 0 1.15rem;
  padding-left: 1.65rem;
}

.markdown-body li {
  margin: 0.42rem 0;
  padding-left: 0.25rem;
  line-height: 1.6;
}

.markdown-body li + li {
  margin-top: 0.48rem;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin: 0.4rem 0 0.55rem;
}

.markdown-body li::marker {
  color: var(--brand-ocean);
}

.markdown-body li input[type="checkbox"] {
  margin-right: 0.45rem;
  vertical-align: -0.08rem;
  accent-color: var(--brand-ocean);
}

.markdown-body a {
  color: var(--brand-ocean);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.markdown-body a:hover {
  opacity: 0.8;
}

.markdown-body code {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--muted);
  padding: 0.08rem 0.32rem;
  font-family: var(--font-mono);
  font-size: 0.84em;
}

.markdown-code-block {
  margin: 1rem 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--brand-night);
  color: var(--brand-night-foreground);
}

.markdown-code-label {
  padding: 0.45rem 0.8rem;
  border-bottom: 1px solid oklch(1 0 0 / 12%);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.72;
}

.markdown-code-block pre {
  margin: 0;
  overflow-x: auto;
  padding: 0.9rem 1rem;
  white-space: pre;
  tab-size: 2;
}

.markdown-code-block pre code {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: 0.8125rem;
  line-height: 1.65;
}

.markdown-body blockquote {
  margin: 1rem 0;
  border-left: 3px solid var(--brand-ocean);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background-color: var(--muted);
  padding: 0.7rem 0.9rem;
  color: var(--muted-foreground);
}

.markdown-body hr {
  height: 1px;
  margin: 1.35rem 0;
  border: 0;
  background-color: var(--border);
}

.markdown-table-wrap {
  width: 100%;
  margin: 1.25rem 0 1.5rem;
  overflow-x: auto;
  border: 1px solid color-mix(in srgb, var(--border) 82%, #8f8a76);
  border-radius: var(--radius-lg);
  background-color: var(--card);
  box-shadow: 0 4px 16px rgb(31 29 20 / 5%);
}

.markdown-body table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}

.markdown-body thead {
  background-color: color-mix(in srgb, var(--secondary) 78%, #f0e992);
}

.markdown-body th,
.markdown-body td {
  padding: 0.78rem 0.9rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: auto;
}

.markdown-body th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--foreground);
}

.markdown-body th:first-child,
.markdown-body td:first-child {
  width: 1%;
  white-space: nowrap;
  text-align: center;
}

.markdown-body th:nth-child(2),
.markdown-body td:nth-child(2) {
  min-width: 20rem;
}

.markdown-body th:last-child,
.markdown-body td:last-child {
  min-width: 13rem;
}

.markdown-body tbody tr:nth-child(even) {
  background-color: color-mix(in srgb, var(--muted) 25%, transparent);
}

.markdown-body th:last-child,
.markdown-body td:last-child {
  border-right: 0;
}

.markdown-body tbody tr:last-child td {
  border-bottom: 0;
}

.markdown-body tbody tr:hover {
  background-color: color-mix(in oklab, var(--muted) 45%, transparent);
}

@media (max-width: 640px) {
  .chat-scroll-inner {
    padding: 1.25rem 0.9rem;
  }

  .chat-message-row:not(.from-user) .chat-bubble {
    max-width: calc(100% - 2.25rem);
  }

  .markdown-body {
    font-size: 0.9rem;
  }

  .markdown-body table {
    min-width: 26rem;
  }
}
.permission-check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  cursor: pointer;
}

.permission-check input {
  width: 1rem;
  height: 1rem;
}

/* Permissões granulares e sugestões de conhecimento */
.permissions-dialog,.suggestion-dialog{position:fixed;inset:0;margin:auto;width:min(42rem,calc(100vw - 2rem));max-height:calc(100vh - 2rem);overflow:auto;border:0;border-radius:.9rem;padding:0;background:var(--background);color:var(--foreground);box-shadow:0 24px 80px rgb(0 0 0/.28)}
.permissions-dialog::backdrop,.suggestion-dialog::backdrop{background:rgb(20 22 19/.52);backdrop-filter:blur(3px)}
.permissions-dialog form,.suggestion-dialog form,.suggestion-detail-dialog{padding:1.4rem}
.permissions-head,.suggestion-dialog-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;padding-bottom:1rem;border-bottom:1px solid var(--border)}
.permissions-head span,.suggestion-dialog-head span{font:600 .58rem var(--font-mono);letter-spacing:.13em;color:#8a7426}
.permissions-head h2,.suggestion-dialog-head h2{margin:.28rem 0 0;font-size:1.15rem}
.permissions-head>button,.suggestion-dialog-head>button{width:2rem;height:2rem;border:0;border-radius:50%;background:transparent;color:var(--muted-foreground);font-size:1.35rem;cursor:pointer}
.permissions-head>button:hover,.suggestion-dialog-head>button:hover{background:var(--muted);color:var(--foreground)}
.permissions-dialog form>p,.suggestion-dialog form>p{margin:.9rem 0;color:var(--muted-foreground);font-size:.8rem;line-height:1.5}
.permissions-list{display:grid;gap:.55rem}.permissions-list label{display:flex;align-items:flex-start;gap:.75rem;padding:.8rem;border:1px solid var(--border);border-radius:.6rem;cursor:pointer}.permissions-list label:hover{background:var(--muted)}.permissions-list input{margin-top:.2rem;width:1rem;height:1rem;accent-color:#9d8a24}.permissions-list strong,.permissions-list small{display:block}.permissions-list strong{font-size:.82rem}.permissions-list small{margin-top:.2rem;color:var(--muted-foreground);font-size:.7rem;line-height:1.4}
.permissions-actions,.suggestion-dialog-actions{display:flex;justify-content:flex-end;gap:.55rem;margin-top:1.2rem}
.suggest-block-button{display:none}
.block-reader img{cursor:default}.block-reader img.suggestion-image-selected{cursor:pointer;outline:3px solid #c8b83e;outline-offset:4px;border-radius:.25rem;filter:saturate(.9)}
.suggestion-dialog label{display:grid;gap:.32rem;margin-top:.8rem;color:var(--muted-foreground);font-size:.72rem}.suggestion-dialog textarea{resize:vertical;line-height:1.5}.suggestion-image-input{padding:.75rem;border:1px dashed var(--border);border-radius:.55rem}.suggestion-image-input input{font-size:.72rem}
.suggestion-card-button{width:100%;text-align:left;color:inherit;cursor:pointer}.suggestion-card-button:hover{border-color:#c8b83e;box-shadow:0 3px 12px rgb(0 0 0/.06)}.suggestion-card.concluida{border-left-color:#3ca76a;opacity:.78}.suggestion-card.descartada{border-left-color:#ad6464;opacity:.64}
.suggestion-detail-dialog{padding:1.4rem}.suggestion-detail-meta{color:var(--muted-foreground);font-size:.72rem}.suggestion-detail-dialog section{margin-top:1rem}.suggestion-detail-dialog h3{margin-bottom:.4rem;font-size:.78rem}.suggestion-detail-dialog pre,.suggestion-detail-dialog section>div{margin:0;padding:.8rem;border:1px solid var(--border);border-radius:.5rem;background:var(--muted);font: .75rem/1.55 var(--font-mono);white-space:pre-wrap;overflow-wrap:anywhere}.suggestion-detail-image{display:block;max-width:100%;max-height:22rem;margin:1rem auto;border-radius:.55rem;border:1px solid var(--border)}
.api-availability-banner{position:fixed;z-index:1000;left:50%;bottom:1rem;transform:translateX(-50%);display:flex;align-items:center;gap:1.25rem;width:min(38rem,calc(100vw - 2rem));padding:.85rem 1rem;border:1px solid #d99b8d;border-radius:.7rem;background:#fff7f4;color:#5d261c;box-shadow:0 12px 40px rgb(0 0 0/.18)}.api-availability-banner div{display:flex;min-width:0;flex:1;flex-direction:column}.api-availability-banner strong{font-size:.8rem}.api-availability-banner span{margin-top:.15rem;font-size:.7rem;line-height:1.4;color:#845247}.api-availability-banner button{flex:0 0 auto;padding:.48rem .7rem;border:1px solid #c88373;border-radius:.42rem;background:#fff;color:#6f2e22;font-size:.7rem;cursor:pointer}.api-availability-banner button:hover{background:#ffebe5}

.users-table .email-cell{cursor:pointer}.users-table .email-cell:hover{text-decoration:underline;text-underline-offset:.18em}
.user-panel-dialog{position:fixed;inset:0;margin:auto;width:min(76rem,calc(100vw - 2rem));height:min(52rem,calc(100vh - 2rem));max-width:none;max-height:none;border:0;border-radius:.9rem;padding:0;background:var(--muted);color:var(--foreground);box-shadow:0 25px 90px rgb(0 0 0/.3)}.user-panel-dialog::backdrop{background:rgb(18 19 16/.56);backdrop-filter:blur(3px)}.user-panel-shell{height:100%;overflow:auto;padding:1.25rem}
.user-panel-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem}.user-panel-header>div>span{font:600 .58rem var(--font-mono);letter-spacing:.14em;color:#88751c}.user-panel-header h2{margin:.3rem 0 .2rem;font-size:1.3rem}.user-panel-header p{color:var(--muted-foreground);font-size:.73rem}.user-panel-header>button{width:2.1rem;height:2.1rem;border:0;border-radius:50%;background:transparent;color:var(--muted-foreground);font-size:1.4rem;cursor:pointer}.user-panel-header>button:hover{background:var(--background)}
.user-panel-toolbar{display:flex;align-items:end;gap:.55rem;flex-wrap:wrap;margin:1.1rem 0}.user-panel-toolbar label{display:grid;gap:.25rem;color:var(--muted-foreground);font-size:.62rem}.user-panel-toolbar .input{width:auto;min-width:9rem;height:2.25rem}
.user-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.65rem}.user-kpis article,.user-chart-card,.user-permissions-card,.user-recent-card{border:1px solid var(--border);border-radius:.7rem;background:var(--background);box-shadow:0 2px 8px rgb(0 0 0/.025)}.user-kpis article{padding:.85rem}.user-kpis span{display:block;color:var(--muted-foreground);font-size:.64rem}.user-kpis strong{display:block;margin-top:.35rem;font-size:1.15rem}
.user-chart-card{margin-top:.65rem;padding:1rem}.user-chart-head h3,.user-permissions-card h3,.user-recent-card h3{font-size:.82rem}.user-chart-head p,.user-permissions-card>div>p,.user-recent-card>div>p{margin-top:.2rem;color:var(--muted-foreground);font-size:.65rem}.user-usage-chart{display:flex;align-items:stretch;gap:3px;height:13rem;margin-top:1rem;padding-top:.5rem;border-bottom:1px solid var(--border);overflow-x:auto}.user-chart-column{display:flex;flex:1 0 10px;min-width:8px;flex-direction:column;justify-content:flex-end;align-items:stretch;height:100%;cursor:help}.user-chart-column>span{min-height:0;border-radius:3px 3px 0 0;background:linear-gradient(180deg,#d6c739,#9f8e18);transition:height .2s ease}.user-chart-column:hover>span{background:#75680e}.user-chart-column small{height:1.4rem;padding-top:.3rem;text-align:center;color:var(--muted-foreground);font-size:.5rem}.user-chart-empty{margin:auto;color:var(--muted-foreground);font-size:.72rem}
.user-panel-columns{display:grid;grid-template-columns:minmax(20rem,.8fr) minmax(25rem,1.2fr);gap:.65rem;margin-top:.65rem}.user-permissions-card,.user-recent-card{padding:1rem}.user-permission-grid{display:grid;grid-template-columns:1fr 1fr;gap:.4rem;margin:.8rem 0}.user-permission-grid label{display:flex;align-items:flex-start;gap:.5rem;padding:.55rem;border:1px solid var(--border);border-radius:.45rem;cursor:pointer}.user-permission-grid label:has(input:checked){border-color:#c7b839;background:#fffcdf}.user-permission-grid input{margin-top:.15rem;accent-color:#8e7d16}.user-permission-grid strong,.user-permission-grid small{display:block}.user-permission-grid strong{font-size:.68rem}.user-permission-grid small{margin-top:.12rem;color:var(--muted-foreground);font-size:.58rem}
.user-recent-runs{display:grid;gap:.3rem;margin-top:.8rem;max-height:19rem;overflow:auto}.user-recent-runs button{display:flex;align-items:center;justify-content:space-between;gap:1rem;width:100%;padding:.55rem;border:0;border-radius:.45rem;background:transparent;text-align:left;color:inherit;cursor:pointer}.user-recent-runs button:hover{background:var(--muted)}.user-recent-runs button>span:last-child{text-align:right}.user-recent-runs strong,.user-recent-runs small{display:block}.user-recent-runs strong{font-size:.67rem}.user-recent-runs small{margin-top:.12rem;color:var(--muted-foreground);font-size:.57rem}
@media(max-width:850px){.user-kpis{grid-template-columns:1fr 1fr}.user-panel-columns{grid-template-columns:1fr}.user-permission-grid{grid-template-columns:1fr}.user-panel-dialog{width:calc(100vw - 1rem);height:calc(100vh - 1rem)}.user-panel-toolbar label{flex:1}.user-panel-toolbar .input{width:100%}}
.block-list.is-selecting-suggestion .block-reader{cursor:text}.block-list.is-selecting-suggestion .block-reader::selection,.block-list.is-selecting-suggestion .block-reader *::selection{background:#f4df58;color:#201d0a}.suggestion-selection-preview{background:#f4df58;color:inherit;padding:.04em .08em;border-radius:.12rem;box-shadow:0 0 0 2px rgb(244 223 88/.35)}
.suggestion-review-highlight{background:#f4df58!important;color:#201d0a!important;box-decoration-break:clone;-webkit-box-decoration-break:clone;box-shadow:0 0 0 3px rgb(244 223 88/.42)}
.suggestion-compose-panel form{display:grid;gap:.75rem;margin-top:.8rem}.suggestion-compose-panel label{display:grid;gap:.3rem;color:var(--muted-foreground);font-size:.67rem}.suggestion-compose-panel textarea{resize:vertical;line-height:1.45}.suggestion-compose-help{margin:.8rem 0;color:var(--muted-foreground);font-size:.68rem;line-height:1.5}.suggestion-compose-actions{display:flex;justify-content:flex-end;gap:.45rem;margin-top:.7rem}.suggestion-review-panel section{margin-top:1rem}.suggestion-review-panel h3{margin-bottom:.35rem;font-size:.72rem}.suggestion-review-panel pre,.suggestion-review-panel section>div{margin:0;padding:.7rem;border:1px solid var(--border);border-radius:.45rem;background:var(--muted);font: .68rem/1.5 var(--font-mono);white-space:pre-wrap;overflow-wrap:anywhere}.suggestion-review-panel #review-suggestion-reason{margin-top:1rem;color:var(--muted-foreground);font-size:.7rem;line-height:1.5}
.admin-section-tabs{display:flex;gap:.25rem;margin:1rem 0 1.2rem;padding:.25rem;border:1px solid var(--border);border-radius:.55rem;background:var(--muted);width:max-content}.admin-section-tabs button{border:0;border-radius:.38rem;background:transparent;padding:.5rem .8rem;color:var(--muted-foreground);font-size:.72rem;cursor:pointer}.admin-section-tabs button.active{background:var(--background);color:var(--foreground);box-shadow:0 1px 4px rgb(0 0 0/.08)}
.suggestion-compose-panel,.suggestion-review-panel{width:23rem}.suggestion-compose-panel .suggestion-proposal-editor{min-height:14rem;font-family:var(--font-sans);font-size:.78rem;line-height:1.6}.suggestion-compose-panel label>small{color:var(--muted-foreground);font-size:.6rem;line-height:1.4}.suggestion-compose-panel .suggestion-compose-actions{position:sticky;bottom:-1rem;margin:0 -1rem -1rem;padding:1rem;background:linear-gradient(180deg,transparent,var(--background) 24%)}
@media(min-width:1450px){.knowledge-workspace.has-insert-panel #knowledge-editor{padding-right:23.5rem}}
.app-message-dialog{position:fixed;inset:0;margin:auto;width:min(27rem,calc(100vw - 2rem));border:0;border-radius:.8rem;padding:0;background:var(--background);color:var(--foreground);box-shadow:0 24px 80px rgb(0 0 0/.3)}.app-message-dialog::backdrop{background:rgb(18 19 16/.5);backdrop-filter:blur(3px)}.app-message-dialog form{padding:1.4rem}.app-message-dialog form>span{font:600 .57rem var(--font-mono);letter-spacing:.14em;color:#89751c}.app-message-dialog h2{margin:.35rem 0 .55rem;font-size:1.08rem}.app-message-dialog p{color:var(--muted-foreground);font-size:.78rem;line-height:1.55;white-space:pre-wrap}.app-message-dialog form>div{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1.2rem}.app-message-dialog .btn-danger{background:#8f3027;color:#fff}

/* Responsividade global */
@media(max-width:1100px){
  .app-header{padding-inline:.8rem}.app-header .brand{gap:.4rem}.app-header .brand .logo{height:48px}.app-header .brand .tag{font-size:.58rem}.nav-link{padding:.4rem .55rem;font-size:.78rem}.session-box{gap:.45rem;margin-left:.35rem;padding-left:.5rem}.session-box .who .name{max-width:10rem;overflow:hidden;text-overflow:ellipsis;font-size:.75rem}.session-box .who .level{font-size:.54rem}
  .knowledge-main{grid-template-columns:18rem minmax(0,1fr)}.knowledge-sidebar{padding:1rem}.knowledge-workspace{padding:1.25rem}.word-page{padding:2.5rem 3rem}.knowledge-toolbar{max-width:100%}
  .agents-main{grid-template-columns:18rem minmax(0,1fr)}.agent-editor{padding:1rem}
  .admin-inner{max-width:calc(100vw - 2rem)}.trace-filters{width:100%}.trace-filters .input{flex:1;min-width:8rem}
}
@media(max-width:800px){
  .app-shell{height:100dvh}.app-header{height:3.5rem;min-height:3.5rem}.app-header .brand .logo{height:42px}.app-header .brand .tag,.session-box .who{display:none}.app-nav{min-width:0}.nav-link{gap:.3rem;padding:.4rem .5rem;font-size:.7rem}.nav-link .icon{width:.9rem;height:.9rem}.session-box{margin-left:.1rem;padding-left:.25rem}.logout-btn{padding:.4rem}
  .chat-layout{flex-direction:column}.chat-sidebar{width:100%;height:11rem;min-height:11rem;border-right:0;border-bottom:1px solid var(--border)}.chat-sidebar-top{display:grid;grid-template-columns:10rem minmax(0,1fr);padding:.5rem}.conversation-list{flex-direction:row;overflow-x:auto;overflow-y:hidden;padding:.15rem .5rem .55rem}.conversation-item{flex:0 0 14rem}.conversation-item .delete-btn{opacity:1}.chat-scroll-inner{padding:1.1rem .85rem;gap:1rem}.chat-empty-state{padding-top:1.5rem}.chat-composer{padding:.45rem}.chat-bubble,.chat-message-row:not(.from-user) .chat-bubble{max-width:calc(100% - 2rem)}
  .knowledge-main{display:flex;height:100%;min-height:0;flex-direction:column}.knowledge-sidebar{flex:0 0 auto;max-height:34vh;border-right:0;border-bottom:1px solid var(--border);padding:.8rem}.knowledge-sidebar-head{margin-bottom:.5rem}.knowledge-sidebar-head h1{font-size:1.1rem}.knowledge-primary-actions{margin:.65rem 0}.knowledge-list-label{margin:.7rem .2rem .35rem}.knowledge-workspace{flex:1;min-height:0;padding:.5rem}.knowledge-toolbar{position:sticky;top:0;padding:.55rem;gap:.5rem}.knowledge-actions{flex-wrap:wrap;justify-content:flex-end}.word-page{min-height:0;padding:1.4rem 1rem;margin-bottom:1rem}.word-title{font-size:1.7rem}.block-number{display:none}.block-head,.block-foot{grid-template-columns:1fr}.metadata-grid{grid-template-columns:1fr}.knowledge-insert-panel,.suggestion-compose-panel,.suggestion-review-panel{top:auto;left:.5rem;right:.5rem;bottom:.5rem;width:auto;max-height:min(72vh,42rem);border-radius:.85rem}.knowledge-workspace.has-insert-panel #knowledge-editor{padding-right:0}
  .admin-inner{max-width:none;padding:1rem .65rem;gap:1rem}.admin-title h1{font-size:1.2rem}.admin-section-tabs{width:100%}.admin-section-tabs button{flex:1}.users-panel-head{align-items:flex-start;flex-direction:column;gap:.65rem}.users-search{width:100%}.add-user-form{grid-template-columns:1fr}.table-wrap{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}.users-table{min-width:44rem}.trace-filters{display:grid;grid-template-columns:1fr 1fr}.trace-filters .input,.trace-filters .btn{width:100%;min-width:0}.trace-detail{padding:.65rem}.trace-steps article>div{flex-direction:column;gap:.25rem}
  .agents-main{display:flex;height:100%;min-height:0;flex-direction:column}.agents-library{flex:0 0 auto;max-height:32vh;border-right:0;border-bottom:1px solid var(--border);padding:.8rem}.agents-head h1{font-size:1.1rem}.agents-list{grid-template-columns:repeat(2,minmax(0,1fr))}.agent-editor{flex:1;min-height:0;overflow:auto;padding:.5rem}.agent-form{padding:1rem}.agent-form-top{align-items:flex-start;gap:.7rem}.agent-form-top>div:last-child{flex-wrap:wrap;justify-content:flex-end}.agent-form-grid{grid-template-columns:1fr}.agent-form-grid .span-2{grid-column:auto}.agent-collections{grid-template-columns:1fr}
  .user-panel-shell{padding:.8rem}.user-panel-toolbar{display:grid;grid-template-columns:1fr 1fr}.user-panel-toolbar label,.user-panel-toolbar .btn{width:100%}.user-kpis{grid-template-columns:1fr 1fr}.user-panel-columns{grid-template-columns:1fr}.user-permission-grid{grid-template-columns:1fr}.user-usage-chart{height:10rem}.permissions-dialog,.suggestion-dialog{width:calc(100vw - 1rem)}
}
@media(max-width:520px){
  .app-header{padding-inline:.45rem}.app-header .brand .logo{width:7.2rem;height:auto}.nav-link{padding:.42rem}.nav-link{font-size:0}.nav-link .icon{width:1.05rem;height:1.05rem}.session-box{border-left:0}.logout-btn .icon{width:1rem;height:1rem}
  .login-page{padding:.75rem}.login-card{width:100%;max-width:100%;padding:1.4rem 1.1rem}.login-card .logo{max-width:11rem}.login-card h1{font-size:1.1rem}
  .chat-sidebar{height:10rem;min-height:10rem}.chat-sidebar-top{grid-template-columns:1fr 1fr}.chat-sidebar-top .btn{font-size:.72rem}.conversation-item{flex-basis:11.5rem}.chat-avatar{width:1.45rem;height:1.45rem}.chat-message-row{gap:.45rem}.chat-composer-inner input{font-size:16px}.agent-picker-wrap select{max-width:12rem}
  .knowledge-sidebar{max-height:30vh}.knowledge-sidebar-head p{display:none}.knowledge-primary-actions{grid-template-columns:1fr}.document-item{padding:.5rem}.knowledge-toolbar{align-items:flex-start}.document-status-wrap{min-width:0}.knowledge-actions{gap:.25rem}.knowledge-actions .btn{padding:.38rem .48rem;font-size:.65rem}.word-title{font-size:1.4rem}.word-summary{font-size:.84rem}.editor-ribbon{overflow-x:auto}.editor-ribbon button{white-space:nowrap}.suggestion-compose-panel,.suggestion-review-panel,.knowledge-insert-panel{left:.25rem;right:.25rem;bottom:.25rem;max-height:78vh}
  .admin-inner{padding:.75rem .45rem}.admin-agents-entry{flex-direction:column}.trace-filters{grid-template-columns:1fr}.user-kpis{grid-template-columns:1fr}.user-panel-toolbar{grid-template-columns:1fr}.user-panel-dialog{width:calc(100vw - .5rem);height:calc(100dvh - .5rem)}.user-panel-header h2{max-width:17rem;overflow-wrap:anywhere}.user-recent-runs button{align-items:flex-start;flex-direction:column}.user-recent-runs button>span:last-child{text-align:left}
  .agents-list{grid-template-columns:1fr}.agent-form-top{flex-direction:column}.agent-form-top>div:last-child{width:100%;justify-content:flex-start}
  .knowledge-confirm,.app-message-dialog{width:calc(100vw - 1rem)}.knowledge-confirm form,.app-message-dialog form{padding:1.1rem}.api-availability-banner{bottom:.5rem;align-items:flex-start;gap:.6rem}.api-availability-banner button{white-space:nowrap}
}
@media(hover:none){.conversation-item .delete-btn{opacity:1}.document-link-list button,.agent-card,.users-table tbody tr{-webkit-tap-highlight-color:transparent}}

/* Navegação móvel em gavetas: chat e biblioteca de conhecimento */
.mobile-drawer-head,.mobile-chat-bar,.mobile-knowledge-bar,.mobile-drawer-backdrop{display:none}
@media(max-width:800px){
  .chat-layout,.knowledge-main{position:relative;display:block;height:100%;min-height:0;overflow:hidden}.knowledge-main{height:calc(100dvh - 3.5rem)}
  .chat-main,.knowledge-workspace{height:100%;min-height:0;width:100%}
  .mobile-chat-bar,.mobile-knowledge-bar{display:flex;flex:0 0 2.8rem;height:2.8rem;align-items:center;gap:.7rem;padding:.4rem .7rem;border-bottom:1px solid var(--border);background:color-mix(in srgb,var(--background) 96%,#f6f1d8);position:relative;z-index:4}
  .mobile-chat-bar button,.mobile-knowledge-bar button{display:flex;align-items:center;gap:.4rem;flex:0 0 auto;border:1px solid var(--border);border-radius:.55rem;background:var(--background);color:var(--foreground);padding:.42rem .65rem;font:600 .72rem var(--font-sans)}
  .mobile-chat-bar button span,.mobile-knowledge-bar button span{font-size:.9rem;line-height:1}
  .mobile-chat-bar strong,.mobile-knowledge-bar strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.76rem;font-weight:600;color:var(--muted-foreground)}
  .mobile-drawer-head{display:flex;align-items:center;justify-content:space-between;min-height:3.1rem;padding:.65rem .8rem;border-bottom:1px solid var(--border)}
  .mobile-drawer-head strong{font-size:.95rem}.mobile-drawer-head button{display:grid;place-items:center;width:2rem;height:2rem;border:0;border-radius:50%;background:var(--muted);font-size:1.25rem;color:var(--foreground)}
  .mobile-drawer-backdrop{display:block;position:fixed;inset:3.5rem 0 0;z-index:39;border:0;background:rgb(20 22 19/.42);backdrop-filter:blur(2px)}
  .mobile-drawer-backdrop[hidden]{display:none}

  .chat-sidebar,.knowledge-sidebar{position:fixed;top:3.5rem;bottom:0;left:0;z-index:40;width:min(88vw,22rem);height:auto;max-height:none;min-height:0;border:0;border-right:1px solid var(--border);box-shadow:14px 0 40px rgb(0 0 0/.18);transform:translateX(-105%);transition:transform .22s ease;overflow:hidden;background:var(--background)}
  .chat-layout.mobile-drawer-open .chat-sidebar,.knowledge-main.mobile-drawer-open .knowledge-sidebar{transform:translateX(0)}
  .chat-sidebar-top{display:flex;flex-direction:column;padding:.75rem}.conversation-list{display:flex;flex:1 1 auto;min-height:0;flex-direction:column;overflow-x:hidden;overflow-y:auto;padding:.15rem .5rem .8rem}.conversation-item{flex:0 0 auto;width:100%;padding:.65rem .55rem}.conversation-item .title{font-size:.84rem}.conversation-item .preview{margin-top:.12rem;font-size:.7rem}.conversation-item .delete-btn{opacity:1;padding:.45rem}
  .chat-main{display:flex;flex-direction:column}.chat-scroll{overscroll-behavior:contain;scroll-padding-bottom:1rem}.chat-scroll-inner{max-width:100%;padding:1rem .75rem 1.4rem;gap:1.1rem}.chat-empty-state{padding:11vh 1rem 1rem}.chat-empty-state h1{font-size:1.25rem}.chat-message-row{gap:.5rem}.chat-bubble,.chat-message-row:not(.from-user) .chat-bubble{max-width:calc(100% - 2rem);font-size:.87rem;line-height:1.55}.chat-bubble.from-user{max-width:88%;padding:.58rem .8rem}.chat-composer{flex:0 0 auto;padding:.45rem max(.55rem,env(safe-area-inset-right)) max(.55rem,env(safe-area-inset-bottom)) max(.55rem,env(safe-area-inset-left));box-shadow:0 -8px 24px rgb(0 0 0/.04)}.composer-shell{max-width:none;border-radius:.85rem;padding:.3rem .4rem .4rem}.agent-picker-wrap select{max-width:min(64vw,17rem)}.chat-composer-inner input{min-height:2.35rem;font-size:16px}.composer-send{width:2.15rem;height:2.15rem;flex-basis:2.15rem}

  .knowledge-sidebar{display:flex;flex-direction:column;padding:0}.knowledge-sidebar>.knowledge-sidebar-head,.knowledge-sidebar>.knowledge-primary-actions,.knowledge-sidebar>.refresh-documents,.knowledge-sidebar>.knowledge-search-wrap,.knowledge-sidebar>.knowledge-list-label{margin-left:.8rem;margin-right:.8rem}.knowledge-sidebar>.knowledge-sidebar-head{margin-top:.8rem}.knowledge-sidebar .document-list{min-height:0;overflow:auto;padding:0 .55rem .8rem}.knowledge-workspace{display:flex;flex-direction:column;padding:0;overflow:hidden}.knowledge-empty{flex:1}.knowledge-workspace>#knowledge-editor{min-height:0;overflow:auto;padding:.5rem}.knowledge-toolbar{top:0;z-index:5;border-radius:.55rem}.word-page{width:100%;max-width:none;margin:0;padding:1.4rem 1rem 4rem;border-radius:.55rem;box-shadow:none}.word-title{font-size:1.55rem}.word-summary{font-size:.85rem}.block-reader{font-size:.9rem;line-height:1.65}.knowledge-block{scroll-margin-top:7rem}
}
@media(max-width:520px){
  .mobile-chat-bar,.mobile-knowledge-bar{padding-inline:.5rem}.mobile-chat-bar button,.mobile-knowledge-bar button{padding:.4rem .55rem}.chat-sidebar,.knowledge-sidebar{width:92vw}.chat-scroll-inner{padding-inline:.6rem}.chat-avatar{display:none}.chat-bubble,.chat-message-row:not(.from-user) .chat-bubble{max-width:100%}.chat-bubble.from-user{max-width:92%}.agent-specifications>div{position:fixed;left:.5rem;right:.5rem;bottom:5.8rem;width:auto}.knowledge-workspace>#knowledge-editor{padding:.3rem}.knowledge-toolbar{padding:.45rem}.word-page{padding:1.15rem .85rem 3rem}.word-title{font-size:1.35rem}.knowledge-actions{width:100%;justify-content:flex-start;overflow-x:auto;flex-wrap:nowrap;padding-bottom:.15rem}.knowledge-actions .btn{flex:0 0 auto;white-space:nowrap}
}

/* Editor de conhecimento adaptável */
@media(max-width:1200px){
  .knowledge-editor.is-editing .knowledge-toolbar{align-items:flex-start;gap:.65rem}.knowledge-editor.is-editing .knowledge-actions{flex-wrap:wrap;justify-content:flex-end}.knowledge-editor.is-editing .word-page{padding:2.2rem 2.5rem}.knowledge-editor.is-editing .block-number{left:-1.8rem}
}
@media(max-width:900px){
  .knowledge-editor.is-editing .knowledge-toolbar{display:grid;grid-template-columns:1fr}.knowledge-editor.is-editing .knowledge-actions{justify-content:flex-start}.knowledge-editor.is-editing .word-page{padding:1.8rem 1.5rem}.knowledge-editor.is-editing .metadata-grid{grid-template-columns:1fr 1fr}.knowledge-editor.is-editing .block-number{display:none}.knowledge-editor.is-editing .block-head{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center}.knowledge-editor.is-editing .block-foot{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center}.knowledge-editor.is-editing .block-keywords{min-width:0}.knowledge-editor.is-editing .block-save{grid-column:auto}.knowledge-editor.is-editing .editor-ribbon{overflow-x:auto;overscroll-behavior-x:contain}.knowledge-editor.is-editing .editor-ribbon>span,.knowledge-editor.is-editing .editor-ribbon button{flex:0 0 auto;white-space:nowrap}
}
@media(max-width:700px){
  .knowledge-editor.is-editing .knowledge-toolbar{position:sticky;top:0;margin-bottom:.4rem;border-radius:.55rem;box-shadow:0 5px 18px rgb(0 0 0/.1)}.knowledge-editor.is-editing .document-status-wrap{width:100%;flex-wrap:wrap;gap:.35rem .55rem}.knowledge-editor.is-editing #save-state{margin-left:auto}.knowledge-editor.is-editing .knowledge-actions{width:100%;display:flex;flex-wrap:nowrap;overflow-x:auto;padding:.1rem 0 .3rem;scrollbar-width:thin}.knowledge-editor.is-editing .knowledge-actions .btn{flex:0 0 auto;min-height:2.15rem;white-space:nowrap}.knowledge-editor.is-editing .word-page{padding:1.25rem .9rem 3rem;border-top-width:3px}.knowledge-editor.is-editing .word-page-kicker{margin-bottom:.9rem}.knowledge-editor.is-editing .word-title{font-size:1.45rem}.knowledge-editor.is-editing .word-summary{padding-left:.7rem;font-size:.88rem}.knowledge-editor.is-editing .doc-metadata{margin:1.2rem 0;padding:.75rem}.knowledge-editor.is-editing .metadata-grid{grid-template-columns:1fr}.knowledge-editor.is-editing .metadata-grid .input{min-height:2.55rem;font-size:16px}.knowledge-editor.is-editing .block-list{gap:1.25rem;margin-top:1.5rem}.knowledge-editor.is-editing .knowledge-block{padding-top:1rem}.knowledge-editor.is-editing .block-head{grid-template-columns:minmax(0,1fr) auto}.knowledge-editor.is-editing .block-title{grid-column:1/-1;font-size:16px}.knowledge-editor.is-editing .block-type{width:100%;min-width:0}.knowledge-editor.is-editing .block-delete{justify-self:end}.knowledge-editor.is-editing .editor-ribbon{margin-top:.5rem;padding:.3rem}.knowledge-editor.is-editing .editor-ribbon>span{display:none}.knowledge-editor.is-editing .editor-ribbon button{min-width:2.5rem;min-height:2.35rem;padding:.45rem .6rem;border-right:1px solid var(--border)}.knowledge-editor.is-editing .block-content{min-height:16rem;padding:.8rem;font:16px/1.6 var(--font-sans)}.knowledge-editor.is-editing .block-foot{grid-template-columns:1fr 1fr}.knowledge-editor.is-editing .block-keywords{grid-column:1/-1;width:100%;font-size:16px}.knowledge-editor.is-editing .block-check{display:flex;align-items:center;gap:.4rem;min-height:2.4rem}.knowledge-editor.is-editing .block-status{width:100%;min-height:2.4rem}.knowledge-editor.is-editing .block-save{grid-column:1/-1;width:100%;min-height:2.6rem}.knowledge-editor.is-editing .empty-add-block{padding:1rem}
}
@media(max-width:420px){
  .knowledge-editor.is-editing .word-page{padding-inline:.7rem}.knowledge-editor.is-editing .edit-mode-label{display:none}.knowledge-editor.is-editing #save-state{width:100%;margin-left:0}.knowledge-editor.is-editing .block-foot{grid-template-columns:1fr}.knowledge-editor.is-editing .block-keywords,.knowledge-editor.is-editing .block-save{grid-column:auto}.knowledge-editor.is-editing .block-check{order:2}.knowledge-editor.is-editing .block-status{order:3}.knowledge-editor.is-editing .block-save{order:4}
}
.nav-brain-icon{display:block;width:1.05rem!important;height:1.05rem!important;flex:0 0 1.05rem;overflow:visible}

.knowledge-editor.has-unsaved-changes #save-document:not(.is-saving):not(.is-saved){background:#eeeb78;border-color:#d9cf46}
.knowledge-editor.is-editing .knowledge-block{transition:background-color .2s ease,box-shadow .2s ease,border-color .2s ease}.knowledge-editor.is-editing .knowledge-block.is-dirty{border-top-color:#d5b900;background:#fffbea;box-shadow:inset 4px 0 0 #e0c900,0 0 0 6px #fffbea;padding:1.4rem 1rem 1rem;border-radius:.25rem}.knowledge-editor.is-editing .knowledge-block.is-dirty .block-content{border-color:#d2b900;background:#fffef7;box-shadow:0 0 0 2px rgb(224 201 0/.15)}.knowledge-editor.is-editing .knowledge-block.is-dirty::after{right:1rem}
.message-sources>.message-source-folders{display:grid;gap:.4rem;max-height:11rem;overflow:auto;margin-top:.4rem;padding-right:.15rem}.message-source-folder{min-width:0}.message-source-folder>header{display:flex;align-items:center;gap:.3rem;margin-bottom:.25rem;color:var(--muted-foreground)}.message-source-folder>header>span{color:#978315;font-size:.58rem}.message-source-folder>header>strong{font-size:.58rem;letter-spacing:.04em;text-transform:uppercase}.message-source-folder>header>small{display:inline-grid;place-items:center;min-width:.9rem;height:.9rem;border-radius:1rem;background:var(--muted);font-size:.48rem}.message-source-folder>div{display:grid;grid-template-columns:repeat(auto-fit,minmax(12rem,1fr));gap:.3rem;padding-left:.55rem;border-left:1px solid #dfcf54}
.message-sources>.message-source-folders{display:grid;gap:.55rem;max-height:none;overflow:visible;padding-right:0}.message-source-folder>strong{display:block;margin-bottom:.22rem;color:var(--foreground);font-size:.58rem;letter-spacing:.06em;text-transform:uppercase}.message-source-folder>.message-source-links{display:flex;flex-direction:column;align-items:flex-start;gap:.15rem;padding:0;border-left:0}.message-source-links>a{max-width:100%;overflow:hidden;color:var(--brand-ocean);font-size:.62rem;line-height:1.35;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:.18em;text-overflow:ellipsis;white-space:nowrap}.message-source-links>a:hover{opacity:.8}
.inline-citation{display:inline-flex;margin-left:.22rem;vertical-align:super;line-height:1}.inline-citation>a{display:inline-grid;place-items:center;min-width:1.05rem;height:1.05rem;padding:0 .18rem;border:1px solid #c9b92f;border-radius:1rem;background:#fff9bf;color:#6c5b00!important;font:700 .52rem var(--font-mono);text-decoration:none!important;transition:background .15s ease,transform .15s ease}.inline-citation>a:hover{background:#f0e76d;opacity:1!important;transform:translateY(-1px)}
.agent-form-grid .field-help{display:block;margin-top:.3rem;color:var(--muted-foreground);font-size:.65rem;line-height:1.35}
