/* ==========================================================================
   IDENTIDADE VISUAL — NSDS (design system da nstech)
   Todas as cores da plataforma saem destes tokens, com os valores do NSDS:
   laranja nstech (#ff3d03), Barlow nos títulos e Open Sans no texto.
   Tema escuro (padrão) = "nst-dark" do NSDS; tema claro = tema padrão do NSDS.
   ========================================================================== */
:root {
  --brand-primary: #ff3d03;        /* laranja nstech (botões, envio, destaques) */
  --brand-primary-hover: #ff5a2a;
  --brand-accent: #ff6a3d;         /* links e ícones de destaque no escuro */
  --brand-gradient: #ff3d03;
  --brand-button: #ff3d03;
  --brand-glow: transparent;

  --bg: #121314;
  --surface: #1b1c1f;
  --surface-2: #25272b;
  --web: #60a5fa;
  --border: #3b3f46;
  --line: #2c2f34;              /* divisórias internas (linhas de tabelas, separadores) */
  --text: #ececec;
  --text-muted: #a9b0b9;
  --primary-soft: rgba(255, 61, 3, 0.14);
  --on-primary: #ffffff;
  --hero-bg: #1b1c1f;
  --code-bg: #0e0f10;

  --success: #22a04f;
  --warning: #d9a13b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);

  --sidebar-bg: #0e0f10;
  --sidebar-border: #2c2f34;
  --sidebar-text: #ececec;
  --sidebar-muted: #a9b0b9;
  --sidebar-hover: #1b1c1f;
  --sidebar-active: #ff3d03;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: none;
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);
  --font: 'Open Sans', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-heading: 'Barlow', 'Segoe UI', system-ui, Arial, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --sidebar-w: 290px;
  /* Altura da barra superior; a marca no menu lateral tem a mesma, para a linha de baixo seguir reta. */
  --topbar-h: 71px;
  --drawer-w: 460px;
  color-scheme: dark;
}

/* Tema claro = tema padrão do NSDS: fundo cinza-claro, cartões brancos, menu grafite (#424449) e
   barra superior branca com a linha laranja embaixo. */
:root[data-theme='light'] {
  --brand-primary-hover: #aa0000;
  --brand-accent: #c23000;         /* laranja mais escuro para texto sobre branco (contraste) */
  --brand-glow: transparent;
  --bg: #f1f2f4;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --web: #1d4ed8;
  --border: #cbd5e1;
  --line: #e2e8f0;
  --text: #1f1f1f;
  --text-muted: #5c636a;
  --placeholder: #6c757d;
  --primary-soft: #fff1ec;
  --hero-bg: #ffffff;
  --code-bg: #1f1f1f;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --warning: #855400;
  --sidebar-bg: #424449;
  --sidebar-border: #55585e;
  --sidebar-text: #ffffff;
  --sidebar-muted: #d0d4d9;
  --sidebar-hover: #4d5056;
  --sidebar-active: #ff3d03;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.2);
  color-scheme: light;
}

/* O menu lateral é grafite no tema claro: lá o laranja de destaque é o do tema escuro. */
:root[data-theme='light'] .sidebar { --brand-accent: #ff6a3d; }
/* Barra superior branca com a linha laranja do NSDS. */
:root[data-theme='light'] .topbar { background: #fff; border-bottom: 2px solid #ff3d03; }
:root[data-theme='light'] .topbar-search:hover { border-color: var(--brand-primary); }
/* Ícones dos documentos no tema claro: fundo cinza-claro, com a cor de cada tipo. */
:root[data-theme='light'] .doc-icon, :root[data-theme='light'] .quick-icon:not(.ai) { background: #f5f5f5; color: #ff3d03; }
:root[data-theme='light'] .doc-icon.file, :root[data-theme='light'] .quick-icon.file { color: #5c636a; }
:root[data-theme='light'] .doc-icon.web, :root[data-theme='light'] .quick-icon.web { color: #1d4ed8; }
:root[data-theme='light'] .media-tile.is-youtube { color: #ff5a52; }
:root[data-theme='light'] .media-tile.is-youtube .tile-duration { color: #ff8a84; }
/* Aba escolhida da tela inicial (Recentes / Mais acessados) em preto. */
:root[data-theme='light'] .home-tabs button.active { background: #1d1f23; color: #fff; }
/* Texto de exemplo dos campos: legível, mas mais claro que o texto digitado. */
:root[data-theme='light'] ::placeholder { color: var(--placeholder); opacity: 1; }

/* ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-family: var(--font-heading); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

i[data-icon] { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1; padding: 28px 32px 104px; max-width: 1180px; width: 100%; margin: 0 auto; outline: none; }

/* ---------- Barra lateral ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 30;
}
/* A marca tem a altura da barra superior e a mesma linha embaixo; não rola junto com o menu. */
.brand {
  flex: none; display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 22px; border-bottom: 1px solid var(--sidebar-border); color: #fff;
}
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 16px 14px 0; }
.brand:hover { text-decoration: none; }
/* Marca: o "A" sobre o livro aberto, em branco, no laranja nstech. */
.brand-mark {
  width: 40px; height: 40px; border-radius: 6px; flex: none; overflow: hidden;
  display: grid; place-items: center;
  background: #ff3d03;
  color: #fff;
  box-shadow: none;
}
/* No menu lateral, a marca fica do tamanho do texto ao lado (na tela de login continua com 40 px). */
.brand .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
/* Logotipo: nome em Barlow e o "by nstech" original embaixo, alinhado à direita. */
.brand-text strong { font-family: var(--font-heading); font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: var(--sidebar-text); }
.brand-text .brand-by { display: block; align-self: flex-end; height: 11px; width: auto; margin-top: 1px; color: var(--sidebar-text); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav-categories a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500;
}
.nav a:hover, .nav-categories a:hover { background: var(--sidebar-hover); text-decoration: none; }
.nav a.active, .nav-categories a.active { background: var(--sidebar-active); color: #fff; }
.nav a.active i, .nav-categories a.active i { color: #fff; }

.nav-actions { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.nav-section { flex: 1; }
.nav-section-title {
  display: flex; justify-content: space-between; align-items: center;
  text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 600;
  color: var(--sidebar-muted); padding: 0 12px 6px;
}
.nav-section-title .icon-link { color: var(--sidebar-muted); display: inline-flex; }
.nav-section-title .icon-link:hover { color: #fff; }
.nav-categories { display: flex; flex-direction: column; gap: 1px; }
.nav-categories a { font-weight: 400; font-size: 14px; padding: 7px 12px; }
.nav-categories .count { margin-left: auto; font-size: 12px; color: var(--sidebar-muted); }
.nav-categories .empty { color: var(--sidebar-muted); font-size: 13px; padding: 4px 12px; }
.sidebar-footer { flex: none; margin: 0 14px; padding: 12px 0 14px; border-top: 1px solid var(--sidebar-border); }
.theme-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; color: var(--sidebar-muted); padding: 8px 12px; cursor: pointer; border-radius: var(--radius-sm);
}
.theme-toggle:hover { background: var(--sidebar-hover); color: #fff; }
/* Versão em uso, embaixo do botão do tema (some com o menu recolhido, como os textos do menu). */
.app-version { padding: 2px 12px 0; font-size: 11.5px; color: var(--sidebar-muted); font-variant-numeric: tabular-nums; cursor: default; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-search {
  flex: 1; max-width: 520px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 12px; color: var(--text-muted); cursor: pointer; text-align: left; font-size: 14px;
}
.topbar-search:hover { border-color: var(--brand-primary); }
.topbar-search span { flex: 1; }
kbd {
  font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface-2);
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { text-decoration: none; border-color: var(--brand-primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-button); border-color: var(--brand-primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn-ia { background: var(--brand-button); border: 0; color: #fff; }
.btn-ia:hover { filter: brightness(1.07); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-ghost-inverse { background: transparent; border-color: var(--sidebar-border); color: var(--sidebar-text); }
.btn-ghost-inverse:hover { background: var(--sidebar-hover); border-color: var(--brand-primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: none; cursor: pointer; color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Elementos comuns ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { font-size: 26px; margin: 0; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 14px; }
.section-title h2 { font-size: 18px; margin: 0; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--primary-soft); color: var(--brand-accent);
}
a.tag:hover { text-decoration: none; filter: brightness(.95); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-muted);
}
.badge-article { color: var(--brand-accent); background: var(--primary-soft); }
.badge-file { color: var(--text-muted); background: var(--surface-2); }
.badge-warn { color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, transparent); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i[data-icon] { width: 42px; height: 42px; color: var(--brand-accent); opacity: .6; margin-bottom: 8px; }
.empty-state h3 { color: var(--text); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--primary-soft); border-top-color: var(--brand-primary);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-muted); padding: 40px; justify-content: center; }

/* ---------- Início ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 6px; padding: 40px 40px 34px;
  background: var(--hero-bg);
  border: 1px solid #30343a;
  color: #f2f2f2;
}
.hero h1 { font-size: 30px; margin-bottom: 6px; position: relative; }
.hero p { color: #9aa0a6; margin: 0 0 22px; max-width: 640px; position: relative; }
.hero-search {
  position: relative; z-index: 1;
  display: flex; gap: 8px; background: #16181b; border: 1px solid #30343a; border-radius: 8px; padding: 6px; max-width: 760px;
}
.hero-search input { flex: 1; border: 0; outline: none; padding: 10px 14px; font-size: 16px; color: #f2f2f2; background: none; min-width: 0; }
.hero-search .btn:not(.btn-ia) { background: #25282d; color: #f2f2f2; border-color: #30343a; }
.hero-search .btn:not(.btn-ia):hover { border-color: var(--brand-primary); }
.hero-search:focus-within { border-color: var(--brand-primary); }
.hero-hint { position: relative; margin-top: 14px; font-size: 13px; color: #9aa0a6; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hero-hint button {
  background: #25282d; color: #e5e5e5; border: 1px solid #30343a;
  border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer;
}
.hero-hint button:hover { border-color: var(--brand-primary); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 20px; }
.stat { padding: 16px 18px; }
.stat strong { display: block; font-size: 26px; }
.stat span { color: var(--text-muted); font-size: 13px; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.category-card { padding: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text); transition: border-color .15s, transform .15s; }
.category-card:hover { text-decoration: none; border-color: var(--brand-primary); transform: translateY(-2px); }
.category-card .cat-icon {
  width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--brand-accent);
}
.category-card strong { font-size: 15px; }
.category-card p { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ---------- Lista de documentos ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filters .search-input { flex: 1; min-width: 220px; }
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc-item { display: flex; gap: 14px; padding: 16px 18px; color: var(--text); transition: border-color .15s; }
.doc-item:hover { text-decoration: none; border-color: var(--brand-primary); }
.doc-icon {
  width: 42px; height: 42px; border-radius: 6px; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--brand-accent);
}
.doc-icon.file { background: var(--surface-2); color: var(--text-muted); }
.doc-icon.web, .quick-icon.web { background: color-mix(in srgb, var(--web) 14%, transparent); color: var(--web); }
.doc-body { min-width: 0; flex: 1; }
.doc-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; overflow-wrap: anywhere; }
.doc-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--text-muted); }
.doc-snippet { margin-top: 6px; font-size: 13.5px; color: var(--text-muted); white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-snippet mark { background: rgba(255, 61, 3, .3); color: var(--text); border-radius: 3px; padding: 0 2px; }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-primary); box-shadow: none; }
.textarea { resize: vertical; min-height: 90px; }
.input-title { font-size: 22px; font-weight: 700; padding: 12px 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Editor de texto ---------- */
.editor { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.editor:focus-within { border-color: var(--brand-primary); box-shadow: none; }
.editor-toolbar { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; align-items: center; }
.editor-toolbar button { background: none; border: 0; border-radius: 6px; padding: 6px 8px; cursor: pointer; color: var(--text-muted); font-weight: 700; min-width: 32px; }
.editor-toolbar button:hover { background: var(--surface); color: var(--text); }
.editor-toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.editor-tabs { margin-left: auto; display: flex; gap: 2px; background: var(--surface); border-radius: 8px; padding: 2px; }
.editor-tabs button { font-weight: 600; font-size: 13px; }
.editor-tabs button.active { background: var(--brand-primary); color: #fff; }
.editor-body { display: grid; grid-template-columns: 1fr; }
.editor-body.split { grid-template-columns: 1fr 1fr; }
.editor textarea {
  width: 100%; min-height: 460px; border: 0; outline: none; resize: vertical; padding: 18px;
  font-family: var(--mono); font-size: 14px; line-height: 1.6; background: var(--surface); color: var(--text);
}
.editor .preview { padding: 18px 22px; min-height: 460px; border-left: 1px solid var(--border); overflow: auto; }
.editor-body:not(.split) .preview { border-left: 0; }

/* ---------- Conteúdo em Markdown ---------- */
.prose { overflow-wrap: anywhere; }
.prose h1 { font-size: 1.6em; margin-top: 1.2em; }
.prose h2 { font-size: 1.3em; margin-top: 1.4em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.1em; margin-top: 1.2em; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .2em 0; }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .15em .4em; border-radius: 5px; }
.prose pre { background: var(--code-bg); color: #e5e5e5; border: 1px solid var(--border); padding: 14px 16px; border-radius: var(--radius-sm); overflow: auto; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose blockquote { border-left: 4px solid var(--brand-primary); background: var(--primary-soft); margin-left: 0; padding: 10px 16px; border-radius: 0 8px 8px 0; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }

/* ---------- Visualização de documento ---------- */
.doc-header { margin-bottom: 18px; }
.doc-header h1 { font-size: 28px; margin: 8px 0 8px; overflow-wrap: anywhere; }
.doc-header .row { gap: 8px; }
.doc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 22px; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.doc-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 86px; }
.doc-side dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.doc-side dt { color: var(--text-muted); }
.doc-side dd { margin: 0; overflow-wrap: anywhere; }
.file-preview { border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.file-preview iframe { width: 100%; height: 75vh; border: 0; display: block; background: #fff; }
.file-preview img, .file-preview video { max-width: 100%; display: block; margin: 0 auto; }
.file-preview audio { width: 100%; }
.extracted {
  white-space: pre-wrap; font-family: var(--mono); font-size: 13px; line-height: 1.6;
  max-height: 560px; overflow: auto; background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0;
}
details.extracted-box summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }

/* ---------- Envio de arquivos ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 44px 20px; text-align: center;
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand-primary); background: var(--primary-soft); }
.dropzone i[data-icon] { width: 40px; height: 40px; color: var(--brand-accent); }
.dropzone h3 { margin: 10px 0 4px; }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand-gradient); width: 0; transition: width .2s; }

/* ---------- Categorias ---------- */
.cat-table { width: 100%; border-collapse: collapse; }
.cat-table th, .cat-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.cat-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.cat-table tr:last-child td { border-bottom: 0; }

/* ---------- Active Corp GPT (chat) ---------- */
.ia { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.ia-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border);
}
.ia-avatar {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--brand-gradient); color: #fff;
}
.ia-avatar { font-weight: 700; font-size: 14px; letter-spacing: .02em; box-shadow: 0 0 14px var(--brand-glow); }
.ia-avatar i[data-icon] { width: 20px; height: 20px; }
.ia-header h2 { font-size: 16px; margin: 0; }
.ia-header small { color: var(--text-muted); font-size: 12px; }
.ia-header .icon-btn { color: var(--text-muted); }
.ia-context {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 12.5px;
  background: var(--primary-soft); color: var(--brand-accent); border-bottom: 1px solid var(--border);
}
.ia-context span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ia-context button { background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; display: inline-flex; }
.ia-messages { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg-user { justify-content: flex-end; }
.msg-user .bubble { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px 14px 4px 14px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ai .ia-avatar { width: 30px; height: 30px; border-radius: 9px; }
.msg-ai .ia-avatar { font-size: 11px; box-shadow: none; }
.msg-ai .bubble { flex: 1; min-width: 0; font-size: 14.5px; }
.msg-ai .bubble.prose p:last-child { margin-bottom: 0; }
.msg-error { color: var(--danger); background: var(--danger-soft); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.msg-ok { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.ia-status { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.ia-status div { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.ia-status div i[data-icon] { width: 14px; height: 14px; color: var(--success); }
.ia-status .spinner { width: 13px; height: 13px; border-width: 2px; }
.ia-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.ia-sources > span { font-size: 12px; color: var(--text-muted); }
.ia-sources a {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text); background: var(--surface-2); max-width: 240px;
}
.ia-sources a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ia-sources a i[data-icon] { width: 13px; height: 13px; color: var(--brand-accent); }
.ia-sources a:hover { border-color: var(--brand-primary); text-decoration: none; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-accent); opacity: .4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; } }

/* Boas-vindas do chat: texto simples alinhado à esquerda, sem selo grande. */
.ia-welcome { text-align: left; padding: 16px 8px; margin: 0; }
.ia-welcome .ia-avatar { display: none; }
.ia-welcome h3 { margin-bottom: 4px; font-size: 16px; }
.ia-welcome p { color: var(--text-muted); font-size: 14px; margin: 0 0 18px; }
.suggestions { display: grid; gap: 8px; text-align: left; }
.suggestions button {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px;
  cursor: pointer; font-size: 13.5px; color: var(--text); text-align: left;
}
.suggestions button:hover { border-color: var(--brand-primary); }

.ia-composer { border-top: 1px solid var(--border); padding: 12px; background: var(--surface); }
.ia-composer form { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 12px; background: var(--surface); }
.ia-composer form:focus-within { border-color: var(--brand-primary); box-shadow: none; }
.ia-composer textarea { flex: 1; border: 0; outline: none; background: none; resize: none; max-height: 180px; padding: 7px 0; line-height: 1.45; }
.ia-composer .send { width: 38px; height: 38px; border-radius: 6px; border: 0; background: var(--brand-primary); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.ia-composer .send:disabled { opacity: .45; cursor: not-allowed; }
.ia-composer .hint { font-size: 11.5px; color: var(--text-muted); text-align: center; margin-top: 6px; }
/* Comandos do chat ("/") */
.ia-composer { position: relative; }
.ia-commands {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); z-index: 6; max-height: 300px; overflow-y: auto;
  padding: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.ia-page .ia-commands { left: max(24px, calc((100% - 820px) / 2)); right: max(24px, calc((100% - 820px) / 2)); }
.ia-commands-title { padding: 4px 10px 6px; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.ia-command {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.ia-command:hover, .ia-command.active { background: var(--primary-soft); }
.ia-command-name { font-family: var(--mono); font-size: 13.5px; font-weight: 600; color: var(--brand-accent); }
.ia-command-args { font-weight: 400; color: var(--text-muted); }
.ia-command-desc { font-size: 12.5px; line-height: 1.4; color: var(--text-muted); }
.ia-commands-foot { margin-top: 4px; padding: 6px 10px 2px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-muted); }
.msg-more { color: var(--text-muted); font-style: italic; }
.msg-command { padding: 1px 6px; border-radius: 6px; background: var(--primary-soft); color: var(--brand-accent); font-family: var(--mono); font-size: .92em; font-weight: 600; }
.ia-unconfigured { margin: 12px 16px 0; padding: 10px 12px; font-size: 13px; border-radius: 6px; background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }

.ia-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 100vw; z-index: 60;
  transform: translateX(100%); transition: transform .25s ease; border-left: 1px solid var(--border);
}
.ia-drawer.open { transform: none; box-shadow: var(--shadow-lg); }
.ia-drawer-inner { height: 100%; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }

.ia-page { height: calc(100vh - 140px); min-height: 480px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.ia-page .ia-messages { padding: 24px max(24px, calc((100% - 820px) / 2)); }
.ia-page .ia-composer { padding: 14px max(24px, calc((100% - 820px) / 2)); }

/* ---------- Diálogo e avisos ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog .dialog-body { padding: 22px; }
dialog h3 { margin-bottom: 14px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: #25282d; border: 1px solid #30343a; color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s ease; max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); }
.form-error { color: var(--danger); margin: 0; }
.audit-alert { color: var(--danger); }
.audit-table td { vertical-align: top; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsivo ---------- */
@media (max-width: 1024px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-side { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; }
  /* Aberto, o menu fica acima da camada escura (.scrim, z-index 50); senão o toque cairia nela e fecharia o menu. */
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); z-index: 60; }
  .topbar .menu-btn { display: inline-grid; }
  :root { --topbar-h: 63px; }
  .topbar { padding: 0 16px; gap: 8px; }
  .btn-ia span { display: none; }
  .btn-ia { padding: 9px 11px; }
  .view { padding: 20px 16px 48px; }
  .hero { padding: 26px 20px; }
  .hero h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .editor-body.split { grid-template-columns: 1fr; }
  .editor-body.split .preview { border-left: 0; border-top: 1px solid var(--border); }
  .ia-page { height: calc(100vh - 120px); }
  .cat-table .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .hero-search { flex-direction: column; }
  .hero-search .btn { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-header h1 { font-size: 22px; }
}

/* ---------- Início (foco na busca) ---------- */
.home { max-width: 860px; margin: 0 auto; }
.home-hero { text-align: center; padding: 48px 0 28px; }
.home-hero h1 { font-size: 30px; margin-bottom: 22px; letter-spacing: -.01em; }
.home-search {
  display: flex; align-items: center; gap: 10px; max-width: 680px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 16px; color: var(--text-muted);
}
.home-search:focus-within { border-color: var(--brand-primary); box-shadow: none; }
.home-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 16px; padding: 10px 0; color: var(--text); }
.home-hint { color: var(--text-muted); font-size: 13px; margin: 12px 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px;
}
.chip:hover { border-color: var(--brand-primary); text-decoration: none; }
.chip i[data-icon] { width: 14px; height: 14px; color: var(--brand-accent); }
.chip span { color: var(--text-muted); font-size: 12px; }
.home-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; margin-top: 12px; }
.home-columns h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px; }
.quick-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.quick-item, .palette-option {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 6px; color: var(--text); min-width: 0;
}
.quick-item:hover, .palette-option:hover, .palette-option.active { background: var(--surface-2); text-decoration: none; }
.quick-icon {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--brand-accent);
}
.quick-icon.file { background: var(--surface-2); color: var(--text-muted); }
.quick-icon.ai { background: var(--brand-gradient); color: #fff; font-weight: 700; font-size: 12px; }
.quick-icon i[data-icon] { width: 16px; height: 16px; }
.quick-text { display: flex; flex-direction: column; min-width: 0; }
.quick-text strong { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-text small { color: var(--text-muted); font-size: 12px; }

/* ---------- Busca rápida (Ctrl+K) ---------- */
.palette-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--text-muted); }
.palette-input input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; color: var(--text); }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-empty { padding: 18px; color: var(--text-muted); font-size: 14px; text-align: center; }

/* ---------- Resposta da Active Corp GPT na busca ---------- */
/* Convite: a Active Corp GPT só responde na busca se a pessoa pedir. */
.ask-ai-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; padding: 12px 16px;
  border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface);
}
.ask-ai-card .ia-avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; box-shadow: none; flex: none; }
.ask-ai-card p { flex: 1; min-width: 200px; margin: 0; font-size: 14px; color: var(--text-muted); }
.ask-ai-card p strong { color: var(--text); }
.answer-card {
  border: 1px solid var(--border); border-left: 3px solid var(--brand-primary); border-radius: var(--radius);
  background: var(--surface); padding: 16px 18px; margin-bottom: 22px;
}
.answer-card header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.answer-card header .ia-avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; box-shadow: none; }
.answer-status { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.answer-status .spinner { width: 13px; height: 13px; }
.answer-body { font-size: 14.5px; }
.answer-body > :last-child { margin-bottom: 0; }
.answer-card footer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.answer-skeleton { display: flex; flex-direction: column; gap: 8px; }
.answer-skeleton span { height: 12px; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
.answer-skeleton span:nth-child(2) { width: 85%; }
.answer-skeleton span:nth-child(3) { width: 60%; }
@keyframes pulse { 50% { opacity: .45; } }

@media (max-width: 860px) {
  .home-hero { padding: 20px 0 16px; }
  .home-hero h1 { font-size: 22px; }
  .home-columns { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .home-hint .kbd-hint { display: none; }
  .topbar-search kbd { display: none; }
  .home-hint kbd { display: none; }
}

/* ---------- Opções de resposta da Active Corp GPT (mesmo estilo da página da Active Corp GPT) ---------- */
.ia-options { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .75rem; }
.ia-option {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: .45rem .95rem; font-size: .85rem; line-height: 1.2; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.ia-option:hover:not(:disabled) {
  border-color: var(--brand-accent); background: var(--surface-2); color: #ffd2c2;
}
:root[data-theme='light'] .ia-option:hover:not(:disabled) { color: var(--brand-primary); }
.ia-option:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.ia-option.chosen { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.ia-option:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.answer-card .ia-options { margin: 4px 0 12px; }

/* ---------- Interações ---------- */
/* Sóbrias de propósito: só cor e borda mudam no hover, sem brilho, salto ou giro. */
.btn { position: relative; }
.btn-ia:hover:not(:disabled) { background: var(--brand-primary-hover); filter: none; }
.doc-item, .category-card, .quick-item, .chip, .suggestions button, .ia-sources a {
  transition: border-color .15s, background .15s;
}
.home-search { transition: border-color .15s, box-shadow .15s; }
.home-search:focus-within { box-shadow: none; }
.ia-drawer { transition: transform .25s ease; }
.ia-composer .send { transition: background .15s; }
.ia-composer .send:hover:not(:disabled) { background: var(--brand-accent); }
.ia-header .icon-btn { transition: background .15s, color .15s; }
.ia-header .icon-btn:hover { color: var(--brand-accent); }
.suggestions button:hover { border-color: var(--brand-accent); }
.theme-transition, .theme-transition * { transition: background-color .3s ease, border-color .3s ease, color .3s ease !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Vídeos e transcrição */
.media-card { padding: 0; overflow: hidden; }
.media-card video { width: 100%; max-height: 70vh; display: block; background: #000; }
.media-card audio { width: calc(100% - 32px); margin: 16px; display: block; }
.transcript { display: flex; flex-direction: column; gap: 12px; }
.transcript-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.transcript-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.transcript-status { display: flex; flex-direction: column; gap: 8px; }
.transcript-status .row { align-items: center; }
.transcript-lines { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.transcript-line { display: flex; gap: 12px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; line-height: 1.55; transition: background .2s; }
.transcript-line:hover { background: var(--surface-2); }
.transcript-line.playing { background: var(--primary-soft); }
.transcript-line .time {
  flex: none; font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--brand-accent);
  background: var(--primary-soft); border: 0; border-radius: 6px; padding: 5px 7px; cursor: pointer; margin-top: 1px;
}
.transcript-line .time:hover { filter: brightness(1.2); }

/* Contador do relatório no menu */
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; text-align: center;
  color: #fff; background: var(--brand-primary);
}
.nav-badge[hidden] { display: none; }
.badge i[data-icon] { width: 12px; height: 12px; margin-right: 3px; vertical-align: -1px; }
.text-warn { color: var(--warning); }

/* Avaliações e ações das respostas */
.vote {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 13px;
  transition: border-color .15s, color .15s, background .15s, transform .15s;
}
.vote i[data-icon] { width: 15px; height: 15px; }
.vote:hover:not(:disabled) { border-color: var(--brand-primary); color: var(--text); transform: translateY(-1px); }
.vote.chosen { border-color: var(--brand-primary); color: var(--brand-accent); background: var(--primary-soft); }
.vote:disabled:not(.chosen) { opacity: .45; cursor: default; }
.answer-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.msg-ai .answer-actions { padding-top: 10px; border-top: 1px solid var(--line); }
.answer-card footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.answer-card footer .answer-actions { margin-top: 0; flex: 1; justify-content: flex-end; }
.answer-note { margin: 10px 0 0; }
.doc-feedback { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Revisão */
.review-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent); background: color-mix(in srgb, var(--warning) 10%, var(--surface));
}
.review-banner > i[data-icon] { width: 22px; height: 22px; color: var(--warning); flex: none; }
.review-banner > div:first-of-type { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.review-banner span { color: var(--text-muted); font-size: 13px; }
.review-row { display: flex; flex-direction: column; gap: 8px; }
.review-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Modelos de texto */
.template-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.template-picker .chip { cursor: pointer; }
.template-picker .chip.active { border-color: var(--brand-primary); background: var(--primary-soft); color: var(--brand-accent); }

/* Histórico de versões */
dialog.history-dialog { width: min(980px, calc(100vw - 32px)); }
.history-dialog h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.history { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; margin-top: 14px; height: min(64vh, 620px); }
.history-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.history-list button {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: none; color: var(--text);
}
.history-list button:hover { background: var(--surface-2); }
.history-list button.active { border-color: var(--brand-primary); background: var(--primary-soft); }
.history-list small { color: var(--text-muted); font-size: 12px; }
.history-preview { overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; }
.history-preview-head { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }

/* YouTube */
.media-youtube { aspect-ratio: 16 / 9; }
.media-youtube iframe { width: 100%; height: 100%; border: 0; display: block; }
.youtube-add { display: flex; flex-direction: column; gap: 12px; }
.youtube-add-head { display: flex; gap: 12px; align-items: center; }
.youtube-add-head > i[data-icon] { width: 28px; height: 28px; color: #ff3d3d; flex: none; }
.youtube-add-head div { display: flex; flex-direction: column; }
.youtube-row { display: flex; gap: 8px; }
.youtube-row .input { flex: 1; min-width: 0; }
.web-add .youtube-add-head > i[data-icon] { color: var(--web); }
.web-status .row { gap: 10px; }
.web-status p, .web-summary p:last-child { margin-bottom: 0; }
.web-summary h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; }
.web-error { display: flex; gap: 8px; align-items: flex-start; }
.web-error svg { flex: none; margin-top: 2px; }
.web-more { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Capítulos */
.chapters { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.chapters-empty { background: none; padding: 0; }
.chapters-head { display: flex; align-items: center; gap: 8px; }
.chapters-head strong { display: flex; align-items: center; gap: 6px; }
.chapters-head strong i[data-icon] { width: 16px; height: 16px; color: var(--brand-accent); }
.chapters-summary { margin: 0; line-height: 1.6; }
.chapter-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.chapter {
  width: 100%; display: flex; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: border-color .15s, background .15s;
}
.chapter:hover { border-color: var(--brand-primary); }
.chapter.playing { border-color: var(--brand-primary); background: var(--primary-soft); }
.chapter .time { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--brand-accent); flex: none; }

/* Relatório */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding: 16px; color: var(--text); transition: border-color .15s, transform .15s; }
.stat:hover { text-decoration: none; border-color: var(--brand-primary); transform: translateY(-2px); }
.stat span { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }
.stat span i[data-icon] { width: 15px; height: 15px; color: var(--brand-accent); }
.stat strong { font-size: 28px; line-height: 1; }
.stat small { color: var(--text-muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--brand-primary); }
.tabs .count { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); margin-left: 4px; }
.report-toolbar { align-items: center; margin-bottom: 12px; gap: 12px; }
.report-toolbar p { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: none; }
.segmented a { padding: 6px 12px; font-size: 13px; color: var(--text-muted); }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.active { background: var(--primary-soft); color: var(--brand-accent); }
.gap-list { display: flex; flex-direction: column; gap: 10px; }
.gap-row { display: flex; gap: 16px; align-items: flex-start; padding: 14px 16px; }
.gap-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.gap-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gap-source { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.gap-source i[data-icon] { width: 12px; height: 12px; }
.gap-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.gap-details summary { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.gap-details ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.gap-details .prose { margin-top: 8px; font-size: 14px; }
.feedback-comment { margin: 0; color: var(--text-muted); font-style: italic; }
.report-section { margin-bottom: 28px; }
.report-section h2 { font-size: 16px; margin-bottom: 12px; }
.feedback-table th i[data-icon] { width: 15px; height: 15px; }
.feedback-table .comments { margin: 0; padding-left: 16px; color: var(--text-muted); font-size: 13px; }

@media (max-width: 860px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history { grid-template-columns: 1fr; height: auto; }
  .history-list { max-height: 180px; }
  .history-preview { max-height: 50vh; }
  .gap-row { flex-direction: column; }
  .gap-actions { justify-content: flex-start; }
  .youtube-row { flex-direction: column; }
}

/* Anexos na conversa com a Active Corp GPT */
.ia-composer .attach {
  width: 34px; height: 34px; margin-left: -6px; border-radius: 9px; border: 0; background: none; color: var(--text-muted);
  cursor: pointer; display: grid; place-items: center; flex: none; transition: color .15s, background .15s;
}
.ia-composer .attach:hover { color: var(--brand-accent); background: var(--primary-soft); }
.ia-composer .attach i[data-icon] { width: 18px; height: 18px; }
.ia-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ia-attachments[hidden] { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 6px 5px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px;
}
.attach-chip.error { border-color: var(--danger); }
.attach-chip i[data-icon] { width: 14px; height: 14px; color: var(--brand-accent); flex: none; }
.attach-chip .attach-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; flex: none; border: 1px solid var(--border); }
.attach-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 500; }
.attach-chip .spinner { width: 12px; height: 12px; }
.attach-chip button { border: 0; background: none; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; padding: 2px; border-radius: 6px; }
.attach-chip button:hover { color: var(--text); background: var(--surface); }
.attach-chip button i[data-icon] { width: 13px; height: 13px; color: inherit; }
.attach-error { color: var(--danger); }
.attach-warn { color: var(--warning); }
.ia.drag .ia-composer form { border-color: var(--brand-primary); border-style: dashed; background: var(--primary-soft); }
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px;
}
.file-chip:hover { text-decoration: none; border-color: var(--brand-primary); }
.file-chip i[data-icon] { width: 14px; height: 14px; color: var(--brand-accent); flex: none; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.temp-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); border: 1px dashed var(--border); background: var(--surface); }
.temp-banner > i[data-icon] { width: 20px; height: 20px; color: var(--brand-accent); flex: none; }
.temp-banner > div { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.temp-banner span { color: var(--text-muted); font-size: 13px; }
.msg-user { flex-direction: column; align-items: flex-end; gap: 6px; }

/* ---------- Tabelas e blocos de código (textos e respostas da Active Corp GPT) ---------- */
.prose .table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--border); border-radius: 6px; }
.prose .table-wrap table { margin: 0; }
.prose table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .94em; }
.prose th, .prose td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
/* Valores longos sem espaço (chaves de acesso, links) quebram em vez de alargar a tabela. */
.prose td { overflow-wrap: anywhere; }
.prose th + th, .prose td + td { border-left: 1px solid var(--line); }
.prose thead th { background: var(--surface-2); font-weight: 600; font-size: .92em; letter-spacing: .01em; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.prose tbody tr:hover td { background: var(--primary-soft); }
.prose .code-block { margin: 0 0 1em; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--code-bg); }
.prose .code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 6px 5px 14px;
  font-size: 12px; font-weight: 600; color: #9aa39a; background: rgba(255, 255, 255, .04); border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.prose .code-block pre { margin: 0; border: 0; border-radius: 0; padding: 12px 14px; white-space: pre; font-size: 13px; line-height: 1.55; tab-size: 4; }
.code-copy {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid transparent; background: none; color: #c9d1c9; font: 600 12px var(--font); transition: background .15s, color .15s;
}
.code-copy:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.code-copy.copied { color: var(--success); }
.code-copy i[data-icon] { width: 14px; height: 14px; }

/* ---------- Ícone de vídeo/áudio com a duração ---------- */
.media-tile {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 6px; background: var(--primary-soft); color: var(--brand-accent);
}
.media-tile.tile-md { width: 42px; height: 42px; }
/* Mesmo tamanho do ícone dos outros documentos na lista da tela inicial (.quick-icon). */
.media-tile.tile-sm { width: 34px; height: 34px; border-radius: 9px; }
.media-tile i[data-icon] { width: 20px; height: 20px; }
.media-tile.has-duration i[data-icon] { width: 17px; height: 17px; }
.media-tile.tile-sm i[data-icon] { width: 16px; height: 16px; }
.media-tile.is-youtube { background: color-mix(in srgb, #ff4e45 14%, transparent); color: #ff5a52; }
.tile-duration { font: 700 9.5px/1 var(--font); letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.media-tile.is-youtube .tile-duration { color: #ff8a84; }

/* ---------- Esqueletos de carregamento ---------- */
.sk {
  display: block; height: 12px; border-radius: 6px; width: 100%;
  background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 70%, var(--text) 8%) 45%, var(--surface-2) 65%);
  background-size: 300% 100%; animation: sk-shimmer 1.3s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-screen { display: flex; flex-direction: column; gap: 14px; }
.sk-stack { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 0; }
.sk-gap { gap: 14px; }
.sk-row { display: flex; gap: 10px; align-items: center; }
.sk-center { margin-left: auto; margin-right: auto; }
.sk-center-row { justify-content: center; margin-top: 18px; }
.sk-h1 { height: 28px; border-radius: 8px; }
.sk-title { height: 16px; }
.sk-sm { height: 10px; }
.sk-icon { width: 42px; height: 42px; border-radius: 6px; flex: none; }
.sk-icon-sm { width: 32px; height: 32px; }
.sk-chip { width: 110px; height: 30px; border-radius: 999px; }
.sk-btn { width: 150px; height: 40px; border-radius: 6px; }
.sk-search { height: 56px; max-width: 680px; border-radius: 8px; margin-top: 18px; }
.sk-input { height: 42px; border-radius: 6px; }
.sk-input-lg { height: 58px; }
.sk-editor { height: 280px; border-radius: 8px; }
.sk-card { pointer-events: none; }
.home.sk-screen { gap: 0; }
.home.sk-screen .home-hero .sk-h1 { margin-top: 8px; }
.home.sk-screen .home-columns section { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Menu lateral recolhível ---------- */
.topbar .menu-btn { display: inline-grid; flex: none; }
.sidebar { transition: width .22s ease, padding .22s ease; }
.sidebar .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a { position: relative; }
@media (min-width: 861px) {
  .sidebar-collapsed .sidebar { width: 76px; }
  .sidebar-collapsed .sidebar-scroll { padding-left: 12px; padding-right: 12px; overflow-x: hidden; }
  .sidebar-collapsed .sidebar-footer { margin-left: 12px; margin-right: 12px; }
  .sidebar-collapsed .sidebar .label,
  .sidebar-collapsed .sidebar .brand-text,
  .sidebar-collapsed .nav-categories .count,
  .sidebar-collapsed .nav-categories .empty { display: none; }
  .sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-collapsed .nav a,
  .sidebar-collapsed .nav-categories a,
  .sidebar-collapsed .theme-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-collapsed .nav-actions .btn { padding-left: 0; padding-right: 0; }
  .sidebar-collapsed .nav-section-title { justify-content: center; }
  .sidebar-collapsed .nav-badge { position: absolute; top: 3px; right: 5px; min-width: 16px; padding: 0 4px; font-size: 10px; }
}

/* ---------- Active Corp GPT fixada ao lado ---------- */
.ia-pin { display: none; }
@media (min-width: 1100px) {
  .ia-pin { display: inline-grid; }
  .ia-drawer.pinned .ia-pin { color: var(--brand-accent); background: var(--primary-soft); }
  body.ia-pinned .main { margin-right: var(--drawer-w); }
  body.ia-pinned .ia-drawer { box-shadow: none; transition: none; }
  body.ia-pinned .main { transition: margin-right .25s ease; }
}

/* ---------- Botão flutuante da Active Corp GPT ---------- */
/* Botão comum com ícone e texto, sem brilho nem animação. */
.ia-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 55;
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px 0 12px; border-radius: 6px; border: 0; cursor: pointer;
  background: var(--brand-primary); color: #fff; font: 600 14px var(--font);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  transition: background .15s;
}
.ia-fab[hidden] { display: none; }
.ia-fab-icon { display: grid; place-items: center; }
.ia-fab-icon i[data-icon] { width: 20px; height: 20px; }
.ia-fab:hover { background: var(--brand-primary-hover); }
.ia-fab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 860px) {
  .ia-fab { right: 16px; bottom: 16px; height: 46px; width: 46px; padding: 0; justify-content: center; }
  .ia-fab .label { display: none; }
}
/* Nas tabelas as palavras não se quebram no meio: a tabela ganha rolagem horizontal. */
.prose th, .prose td { overflow-wrap: normal; word-break: normal; }
.prose td { min-width: 64px; }

/* ---------- Início: painel de trabalho ---------- */
.home { max-width: none; }
.home-header { margin-bottom: 14px; }
.home-search {
  display: flex; align-items: center; gap: 10px; max-width: 720px; margin: 0 0 24px;
  padding: 4px 4px 4px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.home-search > i[data-icon] { color: var(--text-muted); }
.home-search input { font-size: 15px; padding: 7px 0; }
.home-search .btn { padding-top: 7px; padding-bottom: 7px; }
.home-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.home-panel { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.home-panel > header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.home-panel h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.home-rows { display: flex; flex-direction: column; }
.home-row {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line); color: var(--text);
}
.home-row:last-child { border-bottom: 0; }
.home-row:hover { background: var(--surface-2); text-decoration: none; }
.home-row-icon { grid-row: 1 / 3; color: var(--text-muted); padding-top: 2px; }
.home-row-icon i[data-icon] { width: 18px; height: 18px; }
.home-row-icon.web { color: var(--web); }
.home-row-title { grid-column: 2; grid-row: 1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-row-date { grid-column: 3; grid-row: 1; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.home-row-meta { grid-column: 2 / 4; grid-row: 2; font-size: 12px; color: var(--text-muted); }
.home-none { padding: 12px 14px; margin: 0; }
.home.sk-screen .home-panel { padding: 14px; }
@media (max-width: 860px) {
  .home-panels { grid-template-columns: minmax(0, 1fr); }
}
/* Na tela inicial a busca principal já está no centro: a do topo fica escondida. */
body.route-home .topbar-search { visibility: hidden; }

/* ---------- Raciocínio da Active Corp GPT (botão "!" discreto) ---------- */
.analysis-toggle {
  width: 16px; height: 16px; margin-left: 6px; padding: 0; border-radius: 50%; flex: none; cursor: pointer;
  display: inline-grid; place-items: center; vertical-align: middle;
  border: 1px solid var(--border); background: none; color: var(--text-muted);
  font: 700 10px/1 var(--font); opacity: .55; transition: opacity .15s, color .15s, border-color .15s, background .15s;
}
.analysis-toggle:hover, .analysis-toggle:focus-visible { opacity: 1; color: var(--brand-accent); border-color: var(--brand-primary); }
.analysis-toggle.open { opacity: 1; color: #fff; background: var(--brand-primary); border-color: var(--brand-primary); }
.ia-status > div { align-items: center; }
.analysis-panel {
  margin: 2px 0 10px; padding: 8px 10px; border-left: 2px solid var(--brand-primary); border-radius: 0 8px 8px 0;
  background: var(--surface-2); color: var(--text-muted); font-size: 12.5px; line-height: 1.55; overflow-wrap: anywhere;
}
.analysis-panel strong { color: var(--text); font-weight: 600; }
.analysis-title { display: block; margin-bottom: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-accent); }
.answer-card > .analysis-panel { margin: 10px 0 4px; }
.ia-status .analysis-toggle { margin-left: 0; }

/* ---------- Login individual e níveis de acesso ---------- */
/* O servidor bloqueia o que o nível de acesso não permite; aqui só escondemos menus e botões.
   As classes can-view-<tela> e can-edit-<tela> do <body> vêm de /api/me (public/js/access.js). */
body:not(.can-view-documentos) .needs-view-documentos,
body:not(.can-edit-documentos) .needs-edit-documentos,
body:not(.can-view-ia) .needs-view-ia,
body:not(.can-view-relatorio) .needs-view-relatorio,
body:not(.can-edit-relatorio) .needs-edit-relatorio,
body:not(.can-view-glossario) .needs-view-glossario,
body:not(.can-edit-glossario) .needs-edit-glossario,
body:not(.can-view-usuarios) .needs-view-usuarios,
body:not(.can-edit-usuarios) .needs-edit-usuarios,
body:not(.can-view-backups) .needs-view-backups,
body:not(.can-edit-backups) .needs-edit-backups,
body:not(.all-categories) .needs-all-categories { display: none !important; }
body.auth-sso .manual-author { display: none; }

.user-box { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 12px; margin-bottom: 4px; }
.user-box[hidden] { display: none; }
.user-avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-primary); color: #fff; font-size: 12px; font-weight: 700;
}
.user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.user-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-text small { font-size: 11px; color: var(--sidebar-muted); }
.user-logout { color: var(--sidebar-muted); }
.user-logout:hover { background: var(--sidebar-hover); color: #fff; }
@media (min-width: 861px) {
  .sidebar-collapsed .user-box { justify-content: center; padding-left: 0; padding-right: 0; flex-direction: column; }
}

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); color: var(--text); margin: 0; }
.login-card {
  width: 100%; max-width: 380px; text-align: center; padding: 36px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card .brand-mark { margin: 0 auto 14px; }
.login-card h1 { font-size: 26px; margin: 0; font-weight: 700; }
.login-card .login-logo { display: inline-flex; flex-direction: column; margin-bottom: 8px; }
.login-card .login-by { display: block; align-self: flex-end; height: 14px; width: auto; margin-top: 2px; color: var(--text); }
.login-card .msg-error, .login-card .msg-ok { margin: 16px 0 0; text-align: left; }

.badge-meaning { color: var(--brand-accent); background: var(--primary-soft); font-weight: 500; }

.gloss-table td { vertical-align: top; }
.gloss-table .tag { margin: 0 4px 4px 0; }
.users-table td { vertical-align: middle; }
.users-table .select-sm { width: auto; padding: 6px 10px; font-size: 13px; }
.user-inactive td { opacity: .55; }
/* Níveis de acesso: matriz nível × tela e o formulário de permissões. */
.table-scroll { overflow-x: auto; }
.levels-table th, .levels-table td { white-space: nowrap; }
.access-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.access-edit { color: var(--brand-accent); background: var(--primary-soft); }
.access-view { color: var(--text); background: var(--surface-2); }
.access-none { color: var(--text-muted); padding-left: 4px; padding-right: 4px; }
.access-legend { margin-top: 16px; }
.access-legend h3 { margin: 0 0 10px; font-size: 15px; }
.access-legend dl { margin: 0; display: grid; gap: 4px; }
.access-legend dt { font-weight: 600; margin-top: 8px; }
.access-legend dt:first-child { margin-top: 0; }
.access-legend dd { margin: 0; color: var(--text-muted); font-size: 13.5px; }
dialog.level-dialog { width: min(640px, calc(100vw - 32px)); }
.level-categories { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px 4px; margin: 0; display: grid; gap: 8px; }
.level-categories legend { font-weight: 600; padding: 0 4px; }
.level-categories p { margin: 0; }
.level-categories .choice { justify-self: start; }
.category-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 14px; max-height: 220px; overflow-y: auto; padding: 4px 0; }
.category-checks[hidden] { display: none; }
.category-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 150px; max-width: 240px; }
.integration-card { margin-top: 16px; display: grid; gap: 10px; }
.integration-card h3 { margin: 0; font-size: 15px; }
.integration-card p { margin: 0; }
.integration-card .select { max-width: 100%; }
.integration-warning { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 6px; font-size: 13px; background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }
.integration-warning svg { flex: none; margin-top: 2px; }
.access-grid { display: grid; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.access-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding: 10px 12px; background: var(--surface); }
.access-row + .access-row { border-top: 1px solid var(--line); }
.access-area { display: flex; flex-direction: column; min-width: 0; }
.access-help { grid-column: 1 / -1; margin: 0; }
.choice { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.choice label { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: block; padding: 6px 11px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.choice label + label span { border-left: 1px solid var(--line); }
.choice input:checked + span { background: var(--primary-soft); color: var(--brand-accent); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--brand-primary); outline-offset: -2px; }
@media (max-width: 560px) {
  .access-row { grid-template-columns: 1fr; }
  .choice { justify-self: start; }
}
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { accent-color: var(--brand-primary); width: 16px; height: 16px; }
body:not(.can-edit-documentos) .nav { margin-bottom: 18px; }
.user-box .user-logout { width: 30px; height: 30px; flex: none; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin: 22px 0 14px; text-align: left; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.login-form .btn { margin-top: 6px; justify-content: center; }
.login-card .msg-error + .login-form, .login-card .msg-ok + .login-form { margin-top: 14px; }
.temp-password { display: grid; gap: 10px; padding: 14px; border: 1px dashed var(--brand-accent); border-radius: var(--radius-sm); background: var(--primary-soft); }
.temp-password div { display: flex; flex-direction: column; gap: 2px; }
.temp-password code { font-size: 16px; font-weight: 700; letter-spacing: .03em; user-select: all; background: none; padding: 0; }

/* ---------- Fonte da resposta da Active Corp GPT (base geral do GPT Maker) ---------- */
.origin-notice {
  display: flex; gap: 6px; align-items: flex-start; margin: 0 0 8px; padding: 4px 10px; width: fit-content; max-width: 100%;
  border-radius: 999px; font-size: 12px; line-height: 1.45; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.origin-notice i[data-icon] { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.origin-notice strong { color: var(--text); font-weight: 600; }

/* ---------- Validação de EDI: ferramentas no chat e visualizador de linhas ---------- */
.edi-tools { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.edi-tools-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.edi-tools p { margin: 0; }
dialog.edi-dialog { width: min(1120px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.edi-viewer { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 20px; }
.edi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.edi-head h3 { margin: 0 0 2px; }
.edi-head p { margin: 0; }
.edi-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.edi-jump { margin-left: auto; }
.edi-jump .input { width: 150px; padding: 6px 10px; }
.edi-line-issues { margin: 0; padding-left: 18px; }
.edi-problem { color: var(--danger); }
.edi-problem.warn { color: var(--warning); }
.edi-raw-wrap {
  overflow-x: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-family: var(--mono); font-size: 13px; line-height: 1.7;
}
.edi-ruler, .edi-raw { width: max-content; white-space: pre; }
.edi-ruler { font-size: 13px; color: var(--text-muted); opacity: .7; }
.edi-seg { border-bottom: 2px solid var(--border); cursor: default; }
.edi-seg.alt { background: color-mix(in srgb, var(--text) 7%, transparent); }
.edi-seg.warn { background: color-mix(in srgb, var(--warning) 22%, transparent); border-bottom-color: var(--warning); }
.edi-seg.bad { background: color-mix(in srgb, var(--danger) 25%, transparent); border-bottom-color: var(--danger); }
.edi-seg.hl { outline: 2px solid var(--brand-accent); outline-offset: 1px; }
.edi-sp { opacity: .35; }
.edi-missing { color: var(--danger); opacity: .7; }
.edi-extra { background: color-mix(in srgb, var(--danger) 25%, transparent); }
.edi-fields td { vertical-align: top; }
.edi-fields td code { white-space: pre; background: none; padding: 0; }
.edi-fields tr.warn td { background: color-mix(in srgb, var(--warning) 10%, transparent); }
.edi-fields tr.bad td { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.edi-fields tr.hl td { background: color-mix(in srgb, var(--brand-accent) 14%, transparent); }
.edi-fields .nowrap { white-space: nowrap; }
.edi-fields i[data-icon] { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
.edi-remaining { padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.edi-remaining p { margin: 0 0 4px; }
.edi-remaining ul { margin: 0; padding-left: 18px; }
.edi-remaining .btn { margin-top: 2px; }
.edi-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.edi-input { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.edi-input .input { padding: 7px 10px; font-family: var(--mono); }
.edi-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.edi-tools p i[data-icon] { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; color: var(--success); }
