/* Layout — shell (topbar+sidebar+main), page-head, stats-grid, split, login.
 *
 * Design system "Aurora" (tokens em tokens.css). Inclui o fundo aurora
 * (body::before) e o vidro do shell (topbar/sidebar/dropdown).
 *   - Desktop ≥ 960: grid topbar / sidebar / main
 *   - Tablet < 960: sidebar vira drawer offcanvas (transform translateX)
 *   - Mobile < 600: tabs com scroll horizontal (em components.css)
 *   - Superfícies de vidro sobre o fundo aurora; main transparente
 */

/* ─────────────────────────────────────────── App shell */

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "topbar  topbar"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--dur-base) var(--ease-out);
}
.app-shell:has(.sidebar.collapsed) {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* ─────────────────────────────────────────── Topbar */

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
  flex: 1;
  height: 100%;
}

/* Breadcrumb dinâmico no topbar */
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  min-width: 0;
  overflow: hidden;
}
.topbar-breadcrumb:not(:empty) {
  padding-left: var(--space-3);
  border-left: 1px solid var(--border);
  margin-left: var(--space-1);
}
.bc-item {
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}
.bc-item:hover { color: var(--text); }
.bc-current {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bc-sep {
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0.5;
}
@media (max-width: 599px) {
  .topbar-breadcrumb { display: none; }
}

/* Brand Verbum — selo SVG + wordmark "Verbum" + sub "control center" */
.brand-verbum {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text);
}
.verbum-seal {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: block;
}
.brand-divider {
  width: 1px;
  height: 30px;
  background: var(--border-strong);
  flex-shrink: 0;
}
.brand-caption { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.03em;
  text-transform: none;
  color: var(--text);
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin-top: 4px;
}
/* Legacy classes (retrocompat) */
.brand { display: none; }

/* Hamburger / drawer toggle (visível < 960px) */
.drawer-toggle {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-2);
}
.drawer-toggle:hover { background: var(--surface-raised); }
.drawer-toggle svg { display: block; }

/* Direita do topbar (toggle + user pod) */
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Theme toggle — SVG dual com sun/moon controlados por data-theme */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: block; }
/* Default (data-theme não setado): exibe ícone do tema ALVO
 * (= o tema oposto ao atual resolvido). Em dark mostra sol (mudar pra
 * light); em light mostra lua (mudar pra dark). */
.theme-toggle .icon-sun  { display: block; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun  { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
}

/* user-pod (direita) — agora com avatar e nome */
.user-pod {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 6px 4px var(--space-2);
  height: 42px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--text-2);
}
.user-pod-avatar {
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-700));
  color: var(--accent-fg);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
}
.user-pod-meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
}
.user-pod-name {
  font-weight: 600;
  color: var(--text);
}
.user-pod .pill { padding: 2px 8px; font-size: 10px; }
.user-pod button {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-full);
}
/* Logout — icon-only button, com tooltip "Sair (encerra a sessão)". */
.user-pod-logout {
  width: 30px;
  padding: 0 !important;
  color: var(--text-dim);
}
.user-pod-logout:hover:not(:disabled) {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* ─────────────────────────────────────────── Sidebar */

.sidebar {
  grid-area: sidebar;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  border-right: 1px solid var(--glass-border);
  padding: var(--space-4) var(--space-4) var(--space-3);
  overflow-y: auto;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  z-index: 5;
  transition: transform var(--dur-base) var(--ease-out);
  box-sizing: border-box;
}
.sidebar > * { min-width: 0; }
.sidebar-section { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar-spacer { flex: 1; min-height: var(--space-4); }
.sidebar.collapsed { padding-left: 12px; padding-right: 12px; }

/* ─────────── Project dropdown (cabeçalho da sidebar) ─────────── */

.proj-dropdown {
  position: relative;
  width: 100%;
}
.proj-dropdown-trigger {
  /* Reset UA stylesheet do <button> */
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  font: inherit;
  line-height: normal;
  /* Layout */
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: all var(--dur-fast) var(--ease-out);
  box-sizing: border-box;
  overflow: hidden;
}
.proj-dropdown-trigger:hover {
  border-color: var(--accent);
  background: var(--surface-raised);
}
.proj-dropdown.is-open .proj-dropdown-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.proj-dd-avatar {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-700));
  color: var(--accent-fg);
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.proj-dd-avatar.empty {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}
.proj-dd-meta { flex: 1; min-width: 0; line-height: 1.2; }
.proj-dd-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj-dd-slug {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.proj-dd-caret {
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out);
}
.proj-dropdown.is-open .proj-dd-caret { transform: rotate(180deg); }

.proj-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  padding: var(--space-1);
  max-height: 380px;
  overflow-y: auto;
  animation: fadeIn 0.15s ease-out;
}
.proj-dd-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.proj-dd-item:hover { background: var(--surface-raised); color: var(--text); }
.proj-dd-item.is-active {
  background: var(--accent-soft);
  color: var(--text);
}
.proj-dd-item-meta { flex: 1; min-width: 0; }
.proj-dd-empty {
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-sm);
}
.proj-dd-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}
.proj-dd-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--accent);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}
.proj-dd-action:hover { background: var(--accent-soft); }

/* Collapsed: só mostra o avatar do dropdown */
.sidebar.collapsed .proj-dropdown-trigger {
  padding: 6px;
  justify-content: center;
}
.sidebar.collapsed .proj-dd-meta,
.sidebar.collapsed .proj-dd-caret { display: none; }
.sidebar.collapsed .proj-dropdown-menu {
  left: calc(100% + var(--space-2));
  right: auto;
  width: 280px;
  top: 0;
}
/* Esconde scrollbar visualmente (mantém scroll funcional) */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* Cabeçalho com botão de collapse */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-1) 0 var(--space-2);
  gap: var(--space-2);
}
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar-collapse-btn {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.sidebar-collapse-btn:hover {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--border);
}

.sidebar-section-label {
  /* Antes: cinza muito leve (text-muted), 10px, uppercase agressivo.
   * Subido pra text-dim (#6B7280 — readable) e 11px pra ficar legível
   * sem ser dominante. Mantém uppercase mas com tracking menor. */
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 700;
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-family: var(--font-heading);
}

.sidebar.collapsed .sidebar-label { display: none; }

/* ─────────── Nav items (tabs do projeto + plataforma) ─────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
  user-select: none;
  box-sizing: border-box;
}
.nav-item:hover {
  background: var(--surface-raised);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--accent-line);
  border-radius: var(--radius-md);
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.nav-item:hover .nav-icon { opacity: 1; }
.nav-item.is-active .nav-icon { opacity: 1; color: var(--accent); }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-tabs-empty {
  font-size: var(--text-sm);
  padding: var(--space-3);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
  word-break: normal;
}

/* ─────────── Botão de collapse — pequeno, elegante, canto inferior ─── */
.sidebar-collapse-footer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  align-self: flex-end;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: inherit;
  /* Removido o uppercase + letter-spacing — "Recolher" lia "RECOLHER",
   * estilo anomalo de botão admin estilo CLI legacy. Sentence-case casa
   * com o resto do produto. */
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  height: 28px;
}
.sidebar-collapse-footer svg { opacity: 0.85; }
.sidebar-collapse-footer:hover {
  background: var(--surface-raised);
  color: var(--accent);
  border-color: var(--accent-line);
}
.sidebar-collapse-footer:hover svg { opacity: 1; }
.sidebar.collapsed .sidebar-collapse-footer {
  align-self: center;
  width: 28px;
  height: 28px;
  padding: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
  user-select: none;
  position: relative;
}
.nav-link:hover {
  background: var(--surface-raised);
  color: var(--text);
  transform: translateX(1px);
}
.nav-link.active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent-line);
  border-radius: var(--radius-md);
}
.nav-link.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-link svg { opacity: 0.75; flex-shrink: 0; }
.nav-link.active svg { opacity: 1; color: var(--accent); }

/* Project list dentro da sidebar */
.proj-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.proj-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: 6px var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-2);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
  position: relative;
}
.proj-item:hover {
  background: var(--surface-raised);
  color: var(--text);
  transform: translateX(1px);
}
.proj-item.active {
  background: var(--accent-soft);
  color: var(--text);
}
.proj-item.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.proj-meta { min-width: 0; flex: 1; }
.proj-item .slug {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj-item .proj-name {
  font-weight: 500;
  line-height: var(--leading-snug);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj-when { font-size: var(--text-xs); }

/* Avatar dos projetos — inicial colorida + gradient sutil */
.proj-avatar {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-2);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.proj-item.active .proj-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-600));
  border-color: var(--accent);
  color: var(--accent-fg);
}
.proj-item:hover .proj-avatar { border-color: var(--border-strong); }

/* ─────────────────────────────────────────── Main */

.main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  /* Transparente: o fundo aurora (body::before) aparece atrás do conteúdo. */
  background: transparent;
}

/* View Transitions: regiões persistentes (apenas head, tabs agora vivem
 * na sidebar). */
.page-head.project-head { view-transition-name: project-head; }
.tab-panel              { view-transition-name: project-tab-panel; }
.main-inner {
  /* Full-width — sem max-width pra ocupar todo o espaço disponível */
  max-width: none;
  margin: 0;
  width: 100%;
}

/* ─────────────────────────────────────────── Drawer backdrop (mobile) */

.drawer-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  background: var(--overlay);
  z-index: var(--z-drawer);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ─────────────────────────────────────────── Page head */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  /* Reduzido de space-6 (32) → space-4 (16) — menos vazio entre header e
   * conteúdo (especialmente crítico em /chat e /logs onde a viewport é
   * disputada). */
  margin-bottom: var(--space-4);
  gap: var(--space-5);
  flex-wrap: wrap;
}
.page-head h1 {
  /* Page title reduzido: 36px → 28px (--text-xl).
   * Antes ocupava ~25% da altura útil + o cabeçalho do projeto repete
   * o nome no sidebar. Manter peso 700 mas com tamanho mais leve. */
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}
.page-head .sub {
  color: var(--text-dim);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin-top: var(--space-1);
  max-width: 60ch;
}
.page-head-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* Section headers dentro de panels (Workloads, Pods, Componentes globais
 * etc.). Antes herdavam --text-2xl pesado e competiam com page-head.
 * Reduzido pra --text-lg (22px) com peso 600 — claramente sub-hierarquia
 * abaixo de page-head h1 (28px/700). */
.main h2,
.panel h2,
.section-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

/* ─────────────────────────────────────────── Project head (compact)
 *
 * O projeto já é identificado no chip da sidebar. Em cada tab evitamos
 * repetir um banner gigante com nome+slug+desc — em vez disso, uma barra
 * de uma linha com título médio + chip de status + slug em mono, e a
 * descrição condensada em ~1 linha (truncada por -webkit-line-clamp).
 */
/* O cabeçalho usa `.glass` (que NÃO tem padding) — então a barra precisa do
 * seu próprio respiro, senão o conteúdo cola nas bordas (faixa fina/apertada).
 * Padding generoso + cantos chunky (radius-2xl) deixam a barra "premium" como
 * a referência, sem virar um banner gigante. */
.project-head {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-2xl);
  margin-bottom: var(--space-5);
  gap: var(--space-5);
}
.project-head-compact {
  align-items: center;
}
.project-head-compact h1 {
  /* Nome do projeto confiante, mas abaixo do page title default (28).
   * O chip da sidebar já é a identidade primária. */
  font-size: 26px;
  font-weight: 650;
  letter-spacing: var(--tracking-tight);
}
/* Chip âncora maior no cabeçalho (40 → 52) — dá peso visual à barra. */
.project-head .icon-chip {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
}
/* Eyebrow respira um pouco mais do título. */
.project-head .project-head-info { gap: var(--space-2); }
/* Linha de identidade: chip à esquerda + coluna de títulos. Esquerda-alinhada
 * (não centralizada) e flexível, para que as ações fiquem à direita via o
 * `justify-content: space-between` do `.page-head`. */
.project-head-identity {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1 1 auto;
}
.project-head-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  flex: 1 1 auto;
}
.project-head-desc {
  margin-top: 0;
  max-width: 70ch;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-head-actions {
  flex: 0 0 auto;
}
.align-baseline { align-items: baseline; }
.small { font-size: var(--text-xs); }

/* ─────────────────────────────────────────── Grids comuns */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 1100px) {
  .split.cols-2 { grid-template-columns: 1fr 1fr; }
  .split.cols-3 { grid-template-columns: 2fr 1fr; }
}

/* ─────────────────────────────────────────── Login (editorial) */
/* Mudou: sem card, sem gradient. Conteúdo direto sobre o bg. Alinhado
 * a 38% do height (golden ratio) — sensação de "documento". */

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  background: var(--bg);
  padding: var(--space-7) var(--space-5) var(--space-7);
}
.login-screen::before {
  /* spacer com altura 30% para empurrar conteúdo a ~38% do viewport */
  content: "";
  flex: 0 0 30vh;
  max-height: 240px;
}

.login-stack {
  width: 420px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login-mark {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.login-mark h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  margin: 0;
}
.login-mark .caption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}
.login-sub {
  color: var(--text-dim);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin: 0;
  max-width: 38ch;
}

.login-stack form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-3);
}
.login-stack form > button[type="submit"] {
  margin-top: var(--space-2);
  height: 44px;
  font-size: var(--text-md);
}

/* ─────────────────────────────────────────── Responsivo */

@media (max-width: 959px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .app-shell:has(.sidebar.collapsed) {
    grid-template-columns: 1fr;
  }
  .drawer-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    z-index: 50;
    border-right: 1px solid var(--glass-border);
    background: var(--glass-bg-strong);
  }
  .sidebar.open { transform: translateX(0); }
  /* Em mobile, ignora o estado collapsed (drawer fica full width) */
  .sidebar.collapsed { width: var(--sidebar-width); }
  .sidebar.collapsed .sidebar-label,
  .sidebar.collapsed .sidebar-section-label {
    display: revert;
  }
  .sidebar.collapsed .sidebar-header { justify-content: space-between; }
  .sidebar-collapse-btn { display: none; }
  .main { padding: var(--space-5) var(--space-5); }
  .page-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 599px) {
  .main { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
  .user-pod .pill { display: none; }
  .user-pod { padding: 0 var(--space-1) 0 var(--space-2); }
  .brand-sub { display: none; }
  .login-screen { padding: var(--space-5); }
  .login-screen::before { flex-basis: 12vh; }
  .login-stack { width: 100%; }
  .login-mark h1 { font-size: var(--text-3xl); }
}

/* ═══════════════════════════ Fundo "Aurora" ═══════════════════════════════
 * Manchas de cor desfocadas atrás de tudo (body::before) + véu de contraste
 * (body::after). O shell é transparente p/ o aurora vazar. (Consolidado: antes
 * vivia numa camada de override separada.) */

html, body { background: var(--bg); }
.app-shell { background: transparent; }

body::before {
  content: "";
  position: fixed;
  inset: -15%;
  z-index: var(--z-aurora);
  pointer-events: none;
  background:
    radial-gradient(42% 38% at 16% 10%,  var(--aurora-1), transparent 62%),
    radial-gradient(40% 34% at 88% 6%,   var(--aurora-2), transparent 60%),
    radial-gradient(46% 44% at 74% 92%,  var(--aurora-3), transparent 64%),
    radial-gradient(38% 36% at 8% 88%,   var(--aurora-2), transparent 60%);
  will-change: transform;
  animation: aurora-drift 26s var(--ease-in-out) infinite alternate;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-aurora);
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 0%, transparent 40%, rgba(6,7,14,0.45) 100%);
}
:root[data-theme="light"] body::after,
:root:not([data-theme="dark"]) body::after { background: none; }

@keyframes aurora-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-3%, -2.4%, 0) scale(1.08); }
}

/* Fallback: sem backdrop-filter, o vidro vira sólido translúcido legível. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .card, .kpi-card, .stat,
  .topbar, .sidebar, .modal, .toast, .proj-dropdown-menu,
  .user-menu { background: var(--surface); }
}

/* ─────────────────────────────────────────── Layout somente-chat
 * Usuário testador: sem sidebar; chat em tela cheia. Seletor de projeto e
 * menu do usuário ficam no topo à direita. */
.app-shell.chat-only {
  grid-template-columns: 1fr;
  grid-template-areas:
    "topbar"
    "main";
}
/* Seletor de projeto no topo (somente-chat): compacto, menu alinhado à direita */
.topbar .proj-dropdown { width: auto; }
.topbar .proj-dropdown-trigger { height: 42px; padding: 4px 12px; }
.topbar .proj-dropdown-trigger .proj-dd-slug { display: none; }
.topbar .proj-dropdown-menu { left: auto; right: 0; width: 300px; }

/* ─────────────────────────────────────────── Menu do usuário (topo direito) */
.user-menu-wrap { position: relative; display: inline-flex; }
button.user-pod {
  appearance: none; -webkit-appearance: none; font: inherit; cursor: pointer;
}
.user-pod-caret { color: var(--text-muted); display: inline-flex; margin-left: 2px; }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur-strong)) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.user-menu[hidden] { display: none; }
.user-menu-head { padding-bottom: var(--space-2); }
.user-menu-name { font-family: var(--font-heading); font-weight: 700; color: var(--text); }
.user-menu-email { word-break: break-all; }
.user-menu-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
}
.user-menu-divider { height: 1px; background: var(--glass-border); margin: var(--space-1) 0; }
.user-menu-logout {
  appearance: none; -webkit-appearance: none; font: inherit;
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%; padding: 8px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--glass-border); background: var(--glass-bg);
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease-out);
}
.user-menu-logout:hover {
  color: var(--color-danger); background: var(--color-danger-bg);
  border-color: var(--color-danger);
}
