/* ============================================================
   IA-UC — Interface de análise documental
   Design system próprio. Sem dependências externas (self-hosted).
   Identidade: precisão, sobriedade, confiança.
   ============================================================ */

:root {
  /* ---- Paleta oficial UC Technology (extraída de uctechnology.com.br) ----
     navy #0B2A4A · ink #0E1726 · cyan #00C2D1 · cyan-deep #0096A8
     slate #5A6B82 · amber #FFB347 · bg claro #F7FAFC
     Modo escuro: neutros derivados do navy da marca. */
  --bg: #0a1420;
  --surface: #0f1c2d;
  --surface-2: #152538;
  --surface-3: #1d3149;
  --line: #22384f;
  --line-soft: #182a3d;

  --text: #e7eef7;
  --text-2: #93a6bb;
  --text-3: #5f7186;

  /* Acento: ciano da marca UC */
  --accent: #00c2d1;
  --accent-2: #34d4e0;
  --accent-ink: #04222a;
  --accent-wash: rgba(0, 194, 209, .14);
  --accent-line: rgba(0, 194, 209, .38);
  /* Gradiente da marca: navy → cyan */
  --grad: linear-gradient(135deg, #0b2a4a 0%, #0096a8 100%);
  --grad-cyan: linear-gradient(135deg, #00c2d1 0%, #0096a8 100%);

  /* Semânticos (separados do acento) */
  --ok: #2bb673;
  --warn: #ffb347;
  --err: #e5544b;

  --user-bubble: #14273c;

  /* Glass (frosted) + glow da marca — camadas modernas 2026 */
  --glass: rgba(15, 28, 45, .62);
  --glass-line: rgba(120, 190, 220, .12);
  --glow: 0 0 0 1px rgba(0,194,209,.18), 0 8px 32px -8px rgba(0,194,209,.28);
  --glow-strong: 0 0 24px -4px rgba(0,194,209,.5);

  /* Métricas */
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-sm: 9px;
  --sb: 264px;
  --sb-min: 68px;
  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --t: 220ms var(--ease);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 10px 34px -8px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.3);
  --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.6), 0 4px 16px rgba(0,0,0,.35);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* refinamentos tipográficos disponíveis no stack nativo */
:root { font-feature-settings: "cv02","cv03","cv04","cv11"; font-variant-ligatures: common-ligatures; }

/* ---- Tema claro (cores UC: bg #F7FAFC, texto navy #0B2A4A) ---- */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7fafc;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --surface-3: #e3e9f0;
    --line: #d8e0ea;
    --line-soft: #e8edf3;
    --text: #0b2a4a;
    --text-2: #5a6b82;
    --text-3: #93a6bb;
    --accent: #0096a8;
    --accent-2: #0096a8;
    --accent-ink: #ffffff;
    --accent-wash: rgba(0, 194, 209, .10);
    --accent-line: rgba(0, 150, 168, .34);
    --user-bubble: #e6f6f8;
    --glass: rgba(255, 255, 255, .72);
    --glass-line: rgba(11, 42, 74, .08);
    --shadow-sm: 0 1px 2px rgba(11,42,74,.06);
    --shadow: 0 14px 40px -12px rgba(11,42,74,.18), 0 2px 8px rgba(11,42,74,.06);
    --shadow-lg: 0 24px 60px -12px rgba(11,42,74,.2), 0 4px 16px rgba(11,42,74,.1);
  }
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7fafc; --surface: #fff; --surface-2: #eef2f7; --surface-3: #e3e9f0;
  --line: #d8e0ea; --line-soft: #e8edf3; --text: #0b2a4a; --text-2: #5a6b82;
  --text-3: #93a6bb; --accent: #0096a8; --accent-2: #0096a8; --accent-ink: #fff;
  --accent-wash: rgba(0,194,209,.10); --accent-line: rgba(0,150,168,.34); --user-bubble: #e6f6f8;
  --glass: rgba(255,255,255,.72); --glass-line: rgba(11,42,74,.08);
  --shadow-sm: 0 1px 2px rgba(11,42,74,.06);
  --shadow: 0 14px 40px -12px rgba(11,42,74,.18), 0 2px 8px rgba(11,42,74,.06);
  --shadow-lg: 0 24px 60px -12px rgba(11,42,74,.2), 0 4px 16px rgba(11,42,74,.1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); background-clip: padding-box; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  /* desliga só as animações DECORATIVAS/ambiente */
  .shell::before, .welcome .logo-mark { animation: none !important; }
  /* MAS mantém os indicadores de carregando (senão parecem travados) */
  .thinking i { animation: bob 1.4s ease-in-out infinite !important; }
  .status-live::after { animation: sweep 2.2s ease-in-out infinite !important; }
  .status-text { animation: shimmer 2.5s linear infinite !important; }
  .caret { animation: blink 1.05s step-start infinite !important; }
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 500px at 50% -20%, rgba(0,194,209,.12), transparent 70%),
    radial-gradient(600px 400px at 85% 110%, rgba(11,42,74,.4), transparent 65%),
    var(--bg);
}
.login-wrap::before {
  content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,194,209,.14), transparent 60%);
  top: -180px; right: -120px; animation: breathe 12s ease-in-out infinite; pointer-events: none;
}
.login-card {
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-line); border-radius: var(--r-xl);
  padding: 46px 40px; width: 384px; box-shadow: var(--shadow-lg); position: relative; z-index: 1;
  animation: msgIn .5s var(--spring);
}
.login-logo { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.logo-mark {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--grad); display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 16px; letter-spacing: -.02em;
  box-shadow: 0 6px 18px -4px rgba(0,150,168,.6), inset 0 1px 0 rgba(255,255,255,.2);
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.brand span { color: var(--accent-2); }
.sub { color: var(--text-2); font-size: 14px; margin: 0 0 28px; line-height: 1.5; }
label { display: block; font-size: 12px; color: var(--text-2); margin: 18px 0 7px; font-weight: 550;
  letter-spacing: .01em; }
input[type=text], input[type=password] {
  width: 100%; padding: 12px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 14.5px; font-family: inherit; transition: border-color var(--t), box-shadow var(--t);
}
input::placeholder { color: var(--text-3); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.btn {
  margin-top: 26px; width: 100%; padding: 12px; border: none; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14.5px;
  font-family: inherit; cursor: pointer; transition: filter var(--t), transform var(--t);
  box-shadow: 0 4px 14px -4px rgba(0,150,168,.55);
}
/* mantém a cor do texto mesmo quando o botão é um link <a> (evita que
   a regra global a:hover troque a cor e faça o texto sumir no fundo) */
a.btn, a.btn:hover, .btn, .btn:hover { color: var(--accent-ink); }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-sm { width: auto; margin: 0; padding: 9px 16px; font-size: 13px; box-shadow: none; }
/* variantes com texto próprio: garante cor no hover também */
a.btn-ghost, a.btn-ghost:hover, .btn-ghost, .btn-ghost:hover { color: var(--text); }
a.btn-danger, a.btn-danger:hover, .btn-danger, .btn-danger:hover { color: var(--err); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.btn-ghost:hover { border-color: var(--accent); filter: none; }
.btn-danger { background: transparent; color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 40%, transparent); box-shadow: none; }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); filter: none; }
.error { color: var(--err); font-size: 13px; margin-top: 18px; padding: 11px 13px;
  background: color-mix(in srgb, var(--err) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--err) 28%, transparent); border-radius: var(--r-sm); }

/* ============================================================
   SHELL
   ============================================================ */
.shell { display: flex; height: 100vh; overflow: hidden; position: relative; }
/* atmosfera: glow radial da marca que respira devagar no fundo */
.shell::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(680px 460px at 78% -8%, rgba(0,194,209,.10), transparent 62%),
    radial-gradient(560px 420px at 12% 108%, rgba(11,42,74,.28), transparent 60%);
  animation: breathe 14s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { opacity: .75; } 50% { opacity: 1; } }
.shell > * { position: relative; z-index: 1; }

.sidebar {
  width: var(--sb); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  transition: width var(--t); overflow: hidden;
}
.shell.collapsed .sidebar { width: var(--sb-min); }

/* cabeçalho: logo alinhado à mesma grade dos itens (padding 12px lateral) */
.sidebar-head { display: flex; align-items: center; gap: 11px; padding: 16px 14px 12px; height: 60px; }
.sidebar-head .logo-mark { width: 38px; height: 38px; font-size: 14px; border-radius: 11px; flex-shrink: 0; }
.sidebar-title { font-weight: 750; font-size: 16px; letter-spacing: -.03em; white-space: nowrap;
  transition: opacity 160ms var(--ease); }

/* esconde textos ao colapsar (sem ocupar espaço) */
.shell.collapsed .sidebar-title,
.shell.collapsed .nav-label,
.shell.collapsed .uname,
.shell.collapsed .new-chat .lbl {
  opacity: 0; width: 0; overflow: hidden; white-space: nowrap;
}

/* botão "Nova conversa" — sóbrio e discreto (combina com a barra) */
.new-chat {
  margin: 6px 14px 12px; height: 44px; display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--t), border-color var(--t); font-family: inherit; text-decoration: none;
}
.new-chat:hover { background: var(--surface-3); border-color: var(--accent-line); }
.new-chat:active { background: var(--surface-2); }
.new-chat .ic { flex-shrink: 0; width: 20px; height: 20px; display: grid; place-items: center;
  color: var(--accent-2); transition: transform var(--t); }
.new-chat:hover .ic { transform: rotate(90deg); }

/* nav tem altura natural (não estica) — o espaço flexível fica sempre abaixo */
.nav { flex: 0 0 auto; padding: 4px 14px; display: flex; flex-direction: column; gap: 2px;
  overflow-x: hidden; }
.nav-sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
  padding: 14px 12px 5px; font-weight: 650; white-space: nowrap; height: 30px; }

/* itens de navegação — grade consistente, realce por fundo (sem barrinha) */
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 0 0 12px; border-radius: 11px;
  color: var(--text-2); font-size: 14px; cursor: pointer; white-space: nowrap; position: relative;
  transition: background var(--t), color var(--t); text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-wash); color: var(--accent-2); font-weight: 600; }
.nav-item .ic { flex-shrink: 0; width: 20px; height: 20px; display: grid; place-items: center; }
.nav-label { transition: opacity 160ms var(--ease); }

/* ============ MODO COLAPSADO (só ícones, tudo centrado e quadrado) ============ */
.shell.collapsed .sidebar-head { justify-content: center; padding: 16px 0 12px; gap: 0; }
.shell.collapsed .nav { padding: 4px 0; align-items: center; }
.shell.collapsed .nav-sep { opacity: 0; height: 8px; padding: 0; }
.shell.collapsed .nav-item,
.shell.collapsed .new-chat {
  width: 44px; height: 44px; padding: 0; justify-content: center; gap: 0; margin-left: auto; margin-right: auto;
}
.shell.collapsed .new-chat { margin: 6px auto 10px; }
/* ícones mantêm o tamanho normal (20px), só ficam centrados */
.shell.collapsed .ic { width: 20px; height: 20px; }
.shell.collapsed .ic svg { width: 20px; height: 20px; }
.shell.collapsed .user-row { justify-content: center; padding: 8px 0; }
.shell.collapsed .sidebar-foot { padding: 10px 0; }
.shell.collapsed .collapse-btn { margin: 6px auto 8px; width: 44px; }

/* espaçador flexível — ocupa o vão nas telas sem histórico (padrão idêntico) */
.sidebar-spacer { flex: 1 1 auto; }

/* ===== Histórico de conversas (seção dedicada) ===== */
.hist { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto;
  border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 8px; overflow: hidden; }
/* colapsado: histórico some, mas vira espaçador flexível para empurrar o
   botão de recolher para o rodapé (senão ele sobe junto com os ícones) */
.shell.collapsed .hist { border: none; margin: 0; padding: 0; }
.shell.collapsed .hist > * { display: none; }
.hist-head { display: flex; align-items: center; justify-content: space-between;
  padding: 4px 20px 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-3); font-weight: 650; }
.conv-empty { padding: 12px 20px; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.hist-search { display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 7px 11px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 9px; color: var(--text-3);
  transition: border-color var(--t); }
.hist-search:focus-within { border-color: var(--accent-line); color: var(--accent-2); }
.hist-search input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: 13px; font-family: inherit; }
.hist-search input:focus { outline: none; }
.shell.collapsed .hist-search { display: none; }

/* lista de conversas (histórico) */
.conv-list { display: flex; flex-direction: column; gap: 1px; padding: 0 12px 8px;
  overflow-y: auto; overflow-x: hidden; min-height: 0; flex: 1; }
.shell.collapsed .conv-list { display: none; }
.conv-item { display: flex; align-items: center; border-radius: var(--r-sm); color: var(--text-2);
  transition: background var(--t); }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--accent-wash); }
.conv-item.active .conv-title { color: var(--accent-2); }
.conv-title { flex: 1; min-width: 0; padding: 8px 4px 8px 12px; font-size: 13px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-del { flex-shrink: 0; width: 28px; height: 28px; margin-right: 4px; display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-3); cursor: pointer; border-radius: 6px;
  opacity: 0; transition: opacity var(--t), color var(--t), background var(--t); }
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }
/* botão renomear conversa (aparece no hover, junto do excluir) */
.conv-ren { flex-shrink: 0; width: 26px; height: 26px; display: grid; place-items: center;
  border: none; background: transparent; color: var(--text-3); cursor: pointer; border-radius: 6px;
  opacity: 0; transition: opacity var(--t), color var(--t), background var(--t); }
.conv-item:hover .conv-ren { opacity: 1; }
.conv-ren:hover { color: var(--accent-2); background: var(--accent-wash); }
/* dica de atalhos no rodapé do composer */
kbd { display: inline-block; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--surface-2); font-family: var(--mono); font-size: 10.5px; color: var(--text-2); }

/* modal de trocar modelo/especialista */
.switch-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.switch-opt { display: flex; gap: 13px; align-items: flex-start; text-align: left; width: 100%;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
  cursor: pointer; font-family: inherit; color: var(--text); transition: border-color var(--t), background var(--t), transform var(--t); }
.switch-opt:hover { border-color: var(--accent-line); background: var(--surface-3); transform: translateY(-1px); }
.so-ic { flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-2); }
.so-tx b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.so-tx span { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }

.sidebar-foot { padding: 8px 14px 12px; border-top: 1px solid var(--line-soft); }
.user-row { display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 11px; height: 44px; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 12.5px; color: #fff; background: var(--grad-cyan);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), var(--glow);
}
.uname { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; transition: opacity 160ms; }

.collapse-btn {
  margin: 6px 14px 6px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); border-radius: 11px;
  color: var(--text-3); cursor: pointer; transition: color var(--t), border-color var(--t), background var(--t);
}
.collapse-btn:hover { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-wash); }
.collapse-btn .ic { display: grid; place-items: center; transition: transform var(--t); }
.shell.collapsed .collapse-btn .ic { transform: rotate(180deg); }

/* ============================================================
   MAIN / CHAT
   ============================================================ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.main-head {
  display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 62px; flex-shrink: 0;
  border-bottom: 1px solid var(--glass-line);
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  position: sticky; top: 0; z-index: 5;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }

/* ---- dropdown de modelo customizado ---- */
.dropdown { position: relative; }
.dd-trigger {
  display: flex; align-items: center; gap: 9px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 21px; padding: 8px 11px 8px 14px; font-size: 13.5px; color: var(--text); cursor: pointer;
  font-family: inherit; font-weight: 550; transition: border-color var(--t), background var(--t);
}
.dd-trigger:hover { border-color: var(--accent-line); background: var(--surface-3); }
.dd-caret { display: grid; place-items: center; color: var(--text-3); transition: transform var(--t); }
.dropdown.open .dd-caret { transform: rotate(180deg); }
.dd-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 300px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px;
  box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98);
  transform-origin: top left; transition: opacity var(--t), transform var(--t), visibility var(--t);
}
.dropdown.open .dd-menu { opacity: 1; visibility: visible; transform: none; }
.dd-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: none;
  background: transparent; border-radius: var(--r); cursor: pointer; text-align: left; font-family: inherit;
  color: var(--text); transition: background var(--t);
}
.dd-opt:hover { background: var(--surface-2); }
.dd-opt-ic { flex-shrink: 0; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent); }
.dd-opt.selected .dd-opt-ic { background: var(--grad-cyan); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.dd-opt-tx { flex: 1; min-width: 0; }
.dd-opt-tx b { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.dd-opt-tx span { font-size: 12px; color: var(--text-3); line-height: 1.35; }
.dd-check { flex-shrink: 0; color: var(--accent); opacity: 0; transition: opacity var(--t); }
.dd-opt.selected .dd-check { opacity: 1; }
.skill-badge { display: grid; place-items: center; color: var(--accent); }
#skillDropdown .dd-menu { left: auto; right: 0; transform-origin: top right; }
.spacer { flex: 1; }
.head-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer;
  transition: background var(--t), color var(--t); }
.head-btn:hover { background: var(--surface-2); color: var(--text); }

/* topbar mínima (telas sem chat): só o perfil à direita */
.topbar-min { display: flex; align-items: center; height: 62px; padding: 0 22px; flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4); position: sticky; top: 0; z-index: 5; }

/* ===== Menu de perfil (avatar → dropdown) ===== */
.profile { position: relative; flex-shrink: 0; }
.avatar-sm { width: 34px; height: 34px; font-size: 12px; }
.profile-btn { padding: 0; border: none; background: transparent; cursor: pointer; border-radius: 10px;
  display: grid; place-items: center; transition: transform var(--t); }
.profile-btn:hover { transform: scale(1.05); }
.profile-btn .avatar { transition: box-shadow var(--t); }
.profile-btn:hover .avatar { box-shadow: inset 0 1px 0 rgba(255,255,255,.25), var(--glow-strong); }
.profile-menu {
  position: absolute; top: calc(100% + 10px); right: 0; min-width: 232px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px;
  box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98);
  transform-origin: top right; transition: opacity var(--t), transform var(--t), visibility var(--t);
}
.profile.open .profile-menu { opacity: 1; visibility: visible; transform: none; }
.profile-info { display: flex; align-items: center; gap: 12px; padding: 8px 10px 10px; }
.profile-meta { min-width: 0; }
.profile-meta b { display: block; font-size: 14px; font-weight: 650; }
.profile-meta span { font-size: 12px; color: var(--text-3); }
.profile-sep { height: 1px; background: var(--line-soft); margin: 4px 6px 6px; }
.profile-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: none;
  background: transparent; border-radius: var(--r); cursor: pointer; text-align: left; font-family: inherit;
  font-size: 14px; color: var(--text); text-decoration: none; transition: background var(--t); }
.profile-item:hover { background: var(--surface-2); }
.profile-item .pi-ic { flex-shrink: 0; width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-2); }

/* mensagem no modal de trocar senha */
.pw-msg { font-size: 13px; min-height: 18px; }
.pw-msg.err { color: var(--err); }
.pw-msg.ok { color: var(--ok); }

.messages { flex: 1; overflow-y: auto; scroll-behavior: smooth; overscroll-behavior: contain; }
.messages-inner { max-width: 748px; margin: 0 auto; padding: 34px 24px 30px; width: 100%; }

.msg { display: flex; gap: 15px; margin-bottom: 30px; animation: msgIn .42s var(--spring); }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.msg .av {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; margin-top: 1px;
}
.msg.assistant .av { background: var(--grad-cyan);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), var(--glow-strong); }
.msg.user .av { background: var(--surface-3); color: var(--text-2); }
.msg .body { min-width: 0; flex: 1; }
.msg .name { font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px;
  letter-spacing: .005em; }
.msg .bubble { line-height: 1.68; font-size: 15px; color: var(--text); word-wrap: break-word;
  overflow-wrap: anywhere; }
.msg.user .bubble {
  background: var(--user-bubble); border: 1px solid var(--line-soft);
  padding: 12px 15px; border-radius: 3px 14px 14px 14px; display: inline-block;
  white-space: pre-wrap; max-width: 100%;
}

/* markdown */
.bubble p { margin: 0 0 13px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 10px 0 14px; padding-left: 20px; }
.bubble li { margin: 5px 0; padding-left: 3px; }
.bubble li::marker { color: var(--accent-2); }
.bubble strong { font-weight: 650; color: var(--text); }
.bubble code { background: var(--surface-3); padding: 2px 6px; border-radius: 6px; font-size: 13px;
  font-family: var(--mono); border: 1px solid var(--line-soft); }
.bubble pre { background: var(--surface); padding: 15px 16px; border-radius: var(--r); overflow-x: auto;
  margin: 12px 0; border: 1px solid var(--line); }
.bubble pre code { background: none; padding: 0; border: none; font-size: 13px; line-height: 1.6; }
.bubble h1, .bubble h2, .bubble h3 { margin: 18px 0 9px; line-height: 1.3; letter-spacing: -.02em;
  font-weight: 680; text-wrap: balance; }
.bubble h1 { font-size: 20px; } .bubble h2 { font-size: 17.5px; } .bubble h3 { font-size: 15.5px; }
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }

.caret { display: inline-block; width: 8px; height: 16px; border-radius: 2px; background: var(--accent-2);
  margin-left: 2px; vertical-align: text-bottom; animation: blink 1.05s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* revelação da resposta pronta (formatada) — fade-in suave de uma vez */
.bubble.reveal { animation: revealIn .4s var(--ease); }
@keyframes revealIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* pílula de status vivo ("Lendo o documento…") */
.status-live { display: inline-flex; align-items: center; gap: 11px; padding: 9px 16px;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--accent-line); border-radius: 22px;
  color: var(--text-2); font-size: 14px; animation: rise .3s var(--ease);
  box-shadow: var(--glow); position: relative; overflow: hidden; }
/* sweep de luz ciano atravessando a pílula */
.status-live::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(0,194,209,.14) 50%, transparent 80%);
  transform: translateX(-100%); animation: sweep 2.2s ease-in-out infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }
.status-text { font-weight: 550; position: relative; z-index: 1;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-2));
  background-size: 200% auto; -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; animation: shimmer 2.5s linear infinite; }
@keyframes shimmer { to { background-position: 200% center; } }

/* os 3 pontos: onda contínua com glow (animação NÃO reinicia via classe própria) */
.thinking { display: inline-flex; gap: 5px; align-items: center; position: relative; z-index: 1; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 6px rgba(0,194,209,.6); animation: bob 1.4s ease-in-out infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; }
.thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes bob {
  0%,80%,100% { transform: translateY(0) scale(1); opacity: .45; }
  40% { transform: translateY(-6px) scale(1.15); opacity: 1; box-shadow: 0 0 12px rgba(0,194,209,.9); }
}

/* boas-vindas */
.welcome { max-width: 640px; margin: auto; padding: 48px 0; animation: rise .5s var(--ease); }
.welcome-head { display: flex; align-items: center; gap: 15px; margin-bottom: 12px; }
.welcome .logo-mark { width: 52px; height: 52px; font-size: 20px; border-radius: 15px;
  box-shadow: var(--glow-strong), inset 0 1px 0 rgba(255,255,255,.25); animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.welcome h1 { font-size: clamp(22px, 3vw, 28px); font-weight: 750; letter-spacing: -.035em; margin: 0;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent-2)); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }
.welcome .lead { color: var(--text-2); font-size: 15.5px; line-height: 1.55; margin: 0 0 30px; max-width: 90%; }
.grid-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
  font-weight: 600; margin-bottom: 12px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.suggestion {
  text-align: left; padding: 16px 17px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); cursor: pointer; position: relative; overflow: hidden;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t), background var(--t);
  display: flex; gap: 13px; align-items: flex-start;
}
/* brilho que desliza no hover */
.suggestion::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity var(--t);
  background: radial-gradient(320px 120px at var(--mx,50%) -20%, rgba(0,194,209,.12), transparent 70%);
}
.suggestion:hover { border-color: var(--accent-line); transform: translateY(-3px); box-shadow: var(--glow), var(--shadow); background: var(--surface-2); }
.suggestion:hover::before { opacity: 1; }
.suggestion .sic { flex-shrink: 0; width: 36px; height: 36px; border-radius: 11px; display: grid;
  place-items: center; background: var(--accent-wash); color: var(--accent-2);
  transition: transform var(--t), box-shadow var(--t); }
.suggestion:hover .sic { transform: scale(1.08); box-shadow: var(--glow-strong); }
.suggestion .stx b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.suggestion .stx span { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
@media (max-width: 560px) { .suggestions { grid-template-columns: 1fr; } }

/* ============================================================
   COMPOSER
   ============================================================ */
.composer { padding: 6px 24px 20px; flex-shrink: 0; }
.composer-inner { max-width: 748px; margin: 0 auto; }
.file-pill {
  display: none; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 10px 8px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; width: fit-content; max-width: 100%; animation: rise .2s var(--ease); color: var(--text-2); }
.file-pill.show { display: inline-flex; }
.file-pill.err { border-color: color-mix(in srgb, var(--err) 45%, transparent);
  background: color-mix(in srgb, var(--err) 10%, transparent); color: var(--err); }
.file-pill.err .fic { color: var(--err); }
.file-pill.loading .fic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.file-pill .fic { color: var(--accent-2); display: grid; place-items: center; }
.file-pill .fx { cursor: pointer; color: var(--text-3); display: grid; place-items: center; width: 20px; height: 20px;
  border-radius: 6px; transition: background var(--t), color var(--t); }
.file-pill .fx:hover { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }

.input-box {
  display: flex; align-items: flex-end; gap: 6px; background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--glass-line); border-radius: var(--r-xl); padding: 7px 7px 7px 8px;
  box-shadow: var(--shadow-lg); transition: border-color var(--t), box-shadow var(--t), transform var(--t);
  position: relative;
}
/* borda-gradiente sutil da marca ao redor do composer */
.input-box::after {
  content: ""; position: absolute; inset: -1px; border-radius: var(--r-xl); padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgba(0,194,209,.35), transparent 45%, rgba(0,194,209,.12));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; opacity: .6; transition: opacity var(--t);
}
.input-box:focus-within { border-color: transparent; box-shadow: var(--glow), var(--shadow-lg); }
.input-box:focus-within::after { opacity: 1; }
textarea {
  flex: 1; resize: none; min-height: 28px; max-height: 220px; padding: 9px 4px; border: none;
  background: transparent; color: var(--text); font-size: 15px; font-family: inherit; line-height: 1.55;
}
textarea:focus { outline: none; }
textarea::placeholder { color: var(--text-3); }
.icon-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; border: none; cursor: pointer;
  display: grid; place-items: center; transition: background var(--t), color var(--t), filter var(--t);
  background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.send { background: var(--grad-cyan); color: #fff;
  box-shadow: 0 4px 14px -3px rgba(0,194,209,.6), inset 0 1px 0 rgba(255,255,255,.25); }
.icon-btn.send:hover { filter: brightness(1.1); transform: translateY(-1px) scale(1.05); box-shadow: var(--glow-strong), 0 6px 18px -3px rgba(0,194,209,.7); }
.icon-btn.send:active { transform: scale(.96); }
.icon-btn.send:disabled { background: var(--surface-3); color: var(--text-3); cursor: default; box-shadow: none; filter: none; transform: none; }
/* alterna ícone enviar/parar (durante a geração vira quadrado de parar) */
.icon-btn.send .ic-stop { display: none; }
.icon-btn.send.stopping .ic-send { display: none; }
.icon-btn.send.stopping .ic-stop { display: block; }
.icon-btn.send.stopping { background: var(--surface-3); color: var(--err); box-shadow: none; }
.icon-btn.send.stopping:hover { filter: none; transform: scale(1.05); background: color-mix(in srgb, var(--err) 18%, var(--surface-3)); }
.stopped-note { margin-top: 10px; font-size: 12px; color: var(--text-3); font-style: italic; }

/* botão de busca na web (ligado/desligado) */
#webBtn.active { color: var(--accent); background: var(--accent-wash); }
#webBtn.active:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }


/* ===== raciocínio do modelo (colapsável) ===== */
.think-box { margin: 0 0 14px; border: 1px solid var(--line-soft); border-radius: var(--r);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent); overflow: hidden; }
.think-toggle { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 13px; border: none;
  background: transparent; cursor: pointer; font-family: inherit; font-size: 12.5px; color: var(--text-3);
  text-align: left; transition: color var(--t), background var(--t); }
.think-toggle:hover { color: var(--text-2); background: var(--surface-2); }
.think-ic { display: grid; place-items: center; transition: transform var(--t); flex-shrink: 0; }
.think-box.open .think-ic { transform: rotate(90deg); }
.think-count { margin-left: auto; font-size: 11px; opacity: .7; }
.think-body { display: none; padding: 4px 14px 13px; font-size: 12.5px; line-height: 1.6;
  color: var(--text-3); border-top: 1px solid var(--line-soft); max-height: 320px; overflow-y: auto;
  font-family: var(--mono); }
.think-box.open .think-body { display: block; animation: rise .25s var(--ease); }
@media print { .think-box { display: none !important; } }

/* barra de ações das mensagens da IA (copiar + feedback) */
.msg-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity var(--t); }
.msg:hover .msg-actions { opacity: 1; }
.msg-act { width: 30px; height: 30px; display: grid; place-items: center; border: none; background: transparent;
  border-radius: 8px; cursor: pointer; color: var(--text-3); transition: background var(--t), color var(--t); }
.msg-act:hover { background: var(--surface-2); color: var(--text); }
.msg-act.done { color: var(--ok); }
.msg-act.voted { color: var(--accent); background: var(--accent-wash); }
.msg-act.voted[data-act="down"] { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }

/* impressão / exportar em PDF: mostra só a conversa, limpa */
@media print {
  .sidebar, .main-head, .composer, .backdrop, .msg-actions, .caret { display: none !important; }
  .shell::before { display: none !important; }
  body, .shell, .main, .messages { background: #fff !important; color: #000 !important; height: auto !important; overflow: visible !important; display: block !important; }
  .messages-inner { max-width: 100% !important; padding: 0 !important; }
  .msg .bubble { color: #000 !important; }
  .msg.user .bubble { background: #f0f0f0 !important; border: 1px solid #ccc !important; }
  .msg .av { background: #444 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .msg { break-inside: avoid; }
}
.hint { text-align: center; font-size: 11.5px; color: var(--text-3); margin-top: 11px; }

/* ============================================================
   PÁGINAS INTERNAS
   ============================================================ */
.page { flex: 1; overflow-y: auto; }
.container { max-width: 780px; margin: 34px auto; padding: 0 24px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.03em; margin: 0 0 4px; }
.page-sub { color: var(--text-2); font-size: 14px; margin: 0 0 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap; }

/* ===== Página Sobre & Ajuda ===== */
.about-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 20px; }
.tab { padding: 9px 18px; border: none; background: transparent; color: var(--text-2); cursor: pointer;
  border-radius: 9px; font-family: inherit; font-size: 14px; font-weight: 550; transition: all var(--t); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--accent-2); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; animation: rise .3s var(--ease); }
.tab-panel.active { display: block; }
.about-list { margin: 8px 0 0; padding-left: 20px; }
.about-list li { margin: 8px 0; font-size: 14px; color: var(--text-2); line-height: 1.55; }
.about-list li b { color: var(--text); }

/* ===== Tabela de usuários (admin) ===== */
.users-table td { vertical-align: middle; }
.user-cell { display: flex; align-items: center; gap: 11px; }
.user-cell .avatar-sm { width: 32px; height: 32px; font-size: 11px; flex-shrink: 0; }

/* menu de ações por linha (⋯) */
.row-menu { position: relative; display: inline-block; }
.row-menu-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  transition: background var(--t), color var(--t), border-color var(--t); }
.row-menu-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.row-menu-pop {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 184px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px;
  box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity var(--t), transform var(--t), visibility var(--t); text-align: left;
}
.row-menu-pop.open { opacity: 1; visibility: visible; transform: none; }
.row-menu-pop form { margin: 0; }
.rm-item { display: block; width: 100%; text-align: left; padding: 9px 11px; border: none;
  background: transparent; border-radius: 7px; cursor: pointer; font-family: inherit; font-size: 13.5px;
  color: var(--text); text-decoration: none; transition: background var(--t); }
.rm-item:hover { background: var(--surface-2); }
.rm-item.danger { color: var(--err); }
.rm-item.danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); }
.rm-sep { height: 1px; background: var(--line-soft); margin: 5px 4px; }

/* destaque de reincidentes na tela de segurança */
tr.row-warn td { background: color-mix(in srgb, var(--warn) 6%, transparent); }
.tag-warn { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 12px; color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent);
  vertical-align: middle; }

/* banners de feedback (erro/sucesso) */
.banner { padding: 12px 16px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 10px; animation: rise .25s var(--ease); }
.banner::before { font-size: 15px; }
.banner-err { background: color-mix(in srgb, var(--err) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--err) 35%, transparent); color: var(--err); }
.banner-err::before { content: "⚠"; }
.banner-ok { background: color-mix(in srgb, var(--ok) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.banner-ok::before { content: "✓"; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.help-h { font-size: 13px; font-weight: 650; margin: 22px 0 8px; color: var(--text);
  text-transform: uppercase; letter-spacing: .04em; }
.help-h:first-of-type { margin-top: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; margin-bottom: 18px;
  transition: border-color var(--t), box-shadow var(--t); }
.card:hover { border-color: var(--line); box-shadow: var(--shadow); }
.card h2, .card h3 { margin-top: 0; letter-spacing: -.02em; font-weight: 650; }
.card h3 { font-size: 15px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
code { background: var(--surface-3); padding: 2px 7px; border-radius: 6px; font-size: 13px; font-family: var(--mono);
  border: 1px solid var(--line-soft); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550;
  padding: 3px 9px; border-radius: 20px; }
.status-pill.on { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.status-pill.off { color: var(--text-3); background: var(--surface-3); }
.newkey { background: color-mix(in srgb, var(--ok) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 38%, transparent); color: var(--text);
  padding: 15px; border-radius: var(--r); word-break: break-all; margin-top: 15px; font-family: var(--mono);
  font-size: 13px; position: relative; }
.newkey .kk { color: var(--ok); }
.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form input { width: auto; flex: 1; }
.muted { color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
pre.example { white-space: pre; font-size: 12.5px; color: var(--text-2); background: var(--surface-2);
  padding: 16px; border-radius: var(--r); border: 1px solid var(--line-soft); overflow-x: auto;
  font-family: var(--mono); line-height: 1.6; }
.tok { color: var(--accent-2); } .str { color: var(--ok); }

.ic svg { display: block; width: 20px; height: 20px; stroke: currentColor; fill: none;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
/* botão nova-conversa usa fundo escuro → ícone branco mais grosso p/ nitidez */
.new-chat .ic svg { stroke-width: 2.2; }

/* ============================================================
   SKILLS (especialistas)
   ============================================================ */
.skill-form { display: flex; flex-direction: column; gap: 16px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field label { margin: 0; }
.field input[type=text], .field input[type=password], .field textarea, .native-select {
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.field input:focus, .field textarea:focus, .native-select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.native-select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca4b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.field-hint { font-size: 12px; color: var(--text-3); }
.form-actions { display: flex; gap: 10px; align-items: center; }

/* switch (toggle) */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; height: 44px; }
.switch input { display: none; }
.switch .slider { width: 42px; height: 24px; border-radius: 20px; background: var(--surface-3);
  border: 1px solid var(--line); position: relative; transition: background var(--t); flex-shrink: 0; }
.switch .slider::after { content: ""; position: absolute; left: 2px; top: 1px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--text-3); transition: transform var(--t), background var(--t); }
.switch input:checked + .slider { background: var(--accent-wash); border-color: var(--accent-line); }
.switch input:checked + .slider::after { transform: translateX(18px); background: var(--accent); }
.switch-lbl { font-size: 13.5px; color: var(--text-2); }

.skill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .skill-grid { grid-template-columns: 1fr; } }
.skill-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: border-color var(--t); }
.skill-card:hover { border-color: var(--accent-line); }
.skill-card.off { opacity: .6; }
.skill-top { display: flex; align-items: center; gap: 12px; }
.skill-ic { width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent); }
.skill-meta { flex: 1; min-width: 0; }
.skill-meta b { display: block; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.skill-slug { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.skill-desc { margin: 0; font-size: 13.5px; color: var(--text-2); line-height: 1.5; flex: 1; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 48px 20px; display: flex;
  flex-direction: column; align-items: center; gap: 14px; }

/* ===== Base de conhecimento no modal de editar ===== */
.kb-section { border-top: 1px solid var(--line-soft); margin-top: 8px; padding-top: 16px; }
.kb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.kb-add { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.kb-upload { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--r-sm);
  border: 1px dashed var(--line); background: var(--surface-2); color: var(--text-2); cursor: pointer;
  font-size: 13px; transition: border-color var(--t), color var(--t); white-space: nowrap; }
.kb-upload:hover { border-color: var(--accent-line); color: var(--accent-2); }
.kb-link-row { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.kb-link-row input { flex: 1; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 13px; font-family: inherit; }
.kb-link-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.kb-msg { font-size: 12.5px; min-height: 16px; margin: 8px 0 4px; }
.kb-msg.ok { color: var(--ok); } .kb-msg.err { color: var(--err); }
.kb-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-height: 240px; overflow-y: auto; }
.kb-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft); }
.kb-item-ic { flex-shrink: 0; color: var(--accent-2); display: grid; place-items: center; }
.kb-item-info { flex: 1; min-width: 0; }
.kb-item-info b { display: block; font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-item-info span { font-size: 11.5px; color: var(--text-3); }
.kb-open, .kb-del { flex-shrink: 0; width: 30px; height: 30px; display: grid; place-items: center; border: none;
  background: transparent; border-radius: 7px; cursor: pointer; color: var(--text-3); transition: all var(--t); }
.kb-open:hover { color: var(--accent-2); background: var(--accent-wash); }
.kb-del:hover { color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }

/* ============================================================
   PAINEL DE USO (dashboard)
   ============================================================ */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 620px) { .kpi-row { grid-template-columns: 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; }
.kpi-label { display: block; font-size: 12px; color: var(--text-2); text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600; margin-bottom: 8px; }
.kpi-value { font-size: 30px; font-weight: 720; letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: var(--grad-cyan); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* barras por dia */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.bar-col { flex: 1; display: flex; align-items: flex-end; height: 100%; min-width: 3px; }
.bar { width: 100%; background: var(--grad-cyan); border-radius: 3px 3px 0 0; min-height: 3px;
  transition: opacity var(--t); }
.bar-col:hover .bar { opacity: .75; }

/* ranking (usuários/modelos) */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 13.5px; }
.rank-name { width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.rank-name code { font-size: 12px; }
.rank-bar-wrap { flex: 1; height: 8px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.rank-bar { display: block; height: 100%; background: var(--accent); border-radius: 20px; }
.rank-bar.alt { background: #8b5cf6; }
.rank-val { width: 42px; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; flex-shrink: 0; }

.chips-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.usage-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; color: var(--text-2); }
.uc-dot { width: 8px; height: 8px; border-radius: 50%; }
.uc-dot.web { background: var(--accent); }
.uc-dot.api { background: #8b5cf6; }
.skill-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.skill-actions form { margin: 0; }
.skill-kb { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.skill-kb b { color: var(--accent); font-weight: 650; }

/* ============================================================
   MODAL (popup reutilizável)
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: none;
  align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto;
  background: rgba(6, 12, 22, .62); backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; animation: fadeIn .18s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  width: 100%; max-width: 620px; box-shadow: var(--shadow); animation: modalIn .22s var(--ease);
  margin: auto; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 20px 24px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.modal-x { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  border: none; background: transparent; color: var(--text-2); cursor: pointer; transition: background var(--t), color var(--t); }
.modal-x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px;
  border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.modal-lg { max-width: 780px; }

/* linhas de detalhe (key details) */
.detail-row { display: flex; padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .dl { width: 150px; color: var(--text-2); flex-shrink: 0; }
.detail-row .dv { color: var(--text); font-family: var(--mono); font-size: 13px; }
.notice { background: var(--accent-wash); border: 1px solid var(--accent-line); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 13px; color: var(--text-2); margin-top: 16px; line-height: 1.5; }

/* link de conversas na tabela de usuários */
.conv-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent-2);
  padding: 4px 10px; border-radius: 16px; background: var(--accent-wash); transition: all var(--t); }
.conv-link:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

/* leitura de conversa (modal admin) */
.tx-msg { margin-bottom: 16px; }
.tx-role { display: block; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); margin-bottom: 5px; }
.tx-msg.user .tx-role { color: var(--accent-2); }
.tx-bubble { font-size: 14px; line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 11px 14px; }
.tx-msg.user .tx-bubble { background: var(--user-bubble); border-radius: 3px 12px 12px 12px; }

.back-link { display: inline-block; font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.back-link:hover { color: var(--accent); }
.upload-form { display: flex; flex-direction: column; gap: 14px; }
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 30px; border: 2px dashed var(--line); border-radius: var(--r-lg); cursor: pointer;
  background: var(--surface-2); transition: border-color var(--t), background var(--t); text-align: center; }
.file-drop:hover { border-color: var(--accent-line); background: var(--surface-3); }
.fd-ic { color: var(--accent); }
.fd-text { font-size: 14px; color: var(--text-2); word-break: break-all; }

/* mobile */
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 30; height: 100%; box-shadow: var(--shadow); }
  .shell:not(.collapsed) .sidebar { width: var(--sb); }
  .shell.collapsed .sidebar { width: 0; border: none; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20;
    backdrop-filter: blur(2px); }
  .shell:not(.collapsed) .backdrop { display: block; }
  .messages-inner, .composer-inner { max-width: 100%; }
}

/* ============================================================
   AGENTES (tarefas multi-passo)
   ============================================================ */
.agent-list { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.agent-card { display: flex; align-items: flex-start; gap: 13px; width: 100%; text-align: left;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
  cursor: pointer; font-family: inherit; color: var(--text);
  transition: border-color var(--t), background var(--t), transform var(--t); }
.agent-card:hover { border-color: var(--accent-line); background: var(--surface-3); transform: translateY(-1px); }
.agent-card.sel { border-color: var(--accent); background: var(--accent-wash); }
.agent-ic { flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-wash); color: var(--accent-2); }
.agent-card.sel .agent-ic { background: var(--grad-cyan); color: #fff; }
.agent-tx b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.agent-tx span { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.agent-run textarea { width: 100%; padding: 11px 13px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit; resize: vertical; }
.agent-run textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.agent-progress { margin-top: 12px; }
.agent-step { padding: 11px 14px; border-radius: var(--r-sm); font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2); }
.agent-step.running { border-color: var(--accent-line); color: var(--accent-2); }
.agent-step.running::before { content: "⏳ "; }
.agent-step.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }

/* container de vários anexos (lista de chips) */
.file-pills { display: none; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.file-pills.show { display: flex; }
.file-pills .file-pill { margin: 0; max-width: 100%; }
.file-pills .file-pill > span:nth-child(2) {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
