@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* Mesma paleta/fontes do Kanban (kanban.html) — roxo/amarelo/preto/off-white */
:root {
  --luma-purple: #7C5BE6;
  --luma-purple-dark: #6B4ED4;
  --luma-gold: #F7D24E;
  --ink: #0A0A0A;
  --ink-2: #6E6B66;
  --ink-3: #9a968d;
  --bg: #FEFCF7;
  --card-bg: #ffffff;
  --border: #E8E3DA;
  --soft-purple: #EDE7FE;
  --soft-yellow: #FFF3C6;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-md: 0 4px 12px rgba(10, 10, 10, 0.06);
  --shadow-lg: 0 12px 32px rgba(10, 10, 10, 0.10);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.mono { font-family: 'JetBrains Mono', monospace; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-sm);
}

.card h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.card .subtitle {
  color: var(--ink-2);
  font-size: 13px;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 4px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--luma-purple); }

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--luma-purple);
  color: #fff;
  width: 100%;
  margin-top: 20px;
}
.btn-primary:hover { background: var(--luma-purple-dark); }

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
}
.btn-secondary:hover { border-color: var(--luma-purple); color: var(--luma-purple); }

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-success {
  background: #dcfce7;
  color: var(--ok);
  cursor: default;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Com 7-8 botões de ação por linha (admin-console), mesmo quebrando (ver
   .actions-cell) a linha pode precisar de mais largura do que a tela tem —
   em vez de cortar/esconder um botão, deixa rolar na horizontal. */
.table-scroll { overflow-x: auto; }

/* Célula de ações em linhas de tabela (admin-console, configurações) — quebra
   os botões em mais de uma linha quando não cabem todos lado a lado (antes
   era nowrap + encolher, mas com 4-5 botões o texto ficava cortado/sobreposto
   em vez de legível). */
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.actions-cell .btn-sm, .actions-cell button { flex-shrink: 0; }

.btn-sm {
  padding: 5px 7px;
  font-size: 11px;
}

/* Linha "checkbox + texto" dentro de formulários — labels normais do app
   (uppercase, bold, block) não servem aqui, então tem classe própria. */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }

.chip-tela {
  display: inline-block;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}
.chip-tela-todas { color: var(--luma-purple-dark); background: var(--soft-purple); border-color: transparent; }

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.error-msg {
  background: #fee2e2;
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }

.container {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 24px;
}

/* Telas que precisam de tabelas mais largas (ex: admin-console) — usa toda
   a largura disponível do .main-content em vez do teto de 960px. */
.container.container-wide {
  max-width: none;
  margin: 24px 28px;
  padding: 0;
}

/* Tela "Minha empresa" (configuracoes.html) — uma coluna só, largura total:
   usuários + base de dados empilhados (base de dados por último). */
.minha-empresa-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 24px;
  margin: 24px 28px;
}
.minha-empresa-grid .container {
  max-width: none;
  margin: 0;
  padding: 0;
}
.minha-empresa-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

/* Mensagens da tela/bloco Comandos (chat com a IA) */
.cmd-msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 10px; max-width: 85%; font-size: 13px; white-space: pre-wrap; }
.cmd-msg.user { background: var(--soft-purple); margin-left: auto; }
.cmd-msg.assistant { background: #fff; border: 1px solid var(--border); }
.cmd-msg-meta { text-align: right; font-size: 11px; color: var(--ink-2); margin-top: 6px; white-space: nowrap; }
.cmd-proposta { border: 1px solid var(--luma-purple); background: var(--soft-purple); border-radius: 10px; padding: 12px 14px; margin: 8px 0; font-size: 13px; }
.cmd-proposta.executado { border-color: var(--ok); background: #dcfce7; }
.cmd-proposta.falhou { border-color: var(--danger); background: #fee2e2; }

table {
  width: 100%;
  /* 'collapse' ignora border-radius por definição da spec — por isso a borda
     da última linha não fechava direito nos cantos. 'separate' + spacing:0
     dá o mesmo visual (só tem border-bottom nas células, sem bordas laterais,
     então não duplica linha nenhuma) e respeita o arredondamento. */
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

/* Tabelas com <colgroup> de larguras fixas (admin-console, configurações,
   documentos) — sem isso o layout automático ignora o colgroup quando o
   conteúdo (e-mails longos, botões de ação) não cabe, e a tabela extrapola
   a largura do container (ficava sobrepondo a coluna vizinha na tela
   "Minha empresa", dividida ao meio). */
.table-fixed { table-layout: fixed; }
/* Só as células de dados quebram em qualquer ponto (e-mails/nomes longos) —
   nos cabeçalhos (palavra única e curta, tipo "STATUS") isso quebrava letra
   por letra quando a coluna era estreita; sem isso, só quebra em espaço
   (e cabe numa linha só nas larguras usadas aqui). */
.table-fixed td { overflow-wrap: anywhere; }

th { color: var(--ink-2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; background: var(--bg); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ativo, .badge-aprovado { background: var(--soft-purple); color: var(--luma-purple-dark); }
.badge-suspenso, .badge-desativado, .badge-descartado { background: var(--soft-yellow); color: #886B00; }
.badge-novo { background: #dcfce7; color: var(--ok); }
.badge-em_analise { background: #e0e7ff; color: #4338ca; }

.linha {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s;
}
.linha:hover { border-color: var(--luma-purple); }
.linha-titulo { font-weight: 700; font-size: 14px; }
.linha-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

.section {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px;
}
.section-title { font-size: 11px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }

.art-file { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.art-file:last-child { border-bottom: none; }

.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 16px; background: #fff; }

.btn { padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--luma-purple); color: var(--luma-purple); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 10, 10, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }

/* ============================================================
   APP SHELL · menu lateral (sidebar) compartilhado entre telas
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 15px; letter-spacing: -0.02em;
  padding: 2px 10px 22px;
  order: 1;
}
.sidebar-brand .dot { color: var(--luma-purple); }
.sidebar-brand-logo { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; flex-shrink: 0; }

.sidebar-links { display: flex; flex-direction: column; gap: 2px; flex: 1; order: 3; }

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none;
  font-size: 13px; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: var(--soft-purple); color: var(--luma-purple-dark); }
.sidebar-link.active { background: var(--luma-purple); color: #fff; }
.sidebar-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-impersonate-banner {
  order: 0;
  display: flex; flex-direction: column; gap: 6px;
  background: #FFF3C6; color: #886B00;
  border: 1px solid #E8C96B; border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 14px;
  font-size: 11px; font-weight: 700; line-height: 1.4;
}
.sidebar-impersonate-banner button {
  align-self: flex-start;
  background: #886B00; color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 4px 8px;
  font-size: 10px; font-weight: 700; cursor: pointer;
}

.sidebar-tenant-box {
  order: 2;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px; padding-bottom: 14px;
}
.sidebar-footer {
  order: 4;
  border-top: 1px solid var(--border);
  margin-top: 14px; padding-top: 14px;
}
.sidebar-user { font-size: 12px; font-weight: 700; margin-bottom: 10px; line-height: 1.4; padding: 0 2px; }
.sidebar-user-sub { display: block; font-weight: 400; color: var(--ink-2); margin-top: 1px; }
.sidebar-tenant-label { font-size: 11px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; padding: 0 2px; }
.sidebar-tenant-sel {
  width: 100%; margin-bottom: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--luma-purple);
  background: var(--soft-purple); color: var(--ink); font-size: 12px; font-weight: 700;
}

.main-content { flex: 1; min-width: 0; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.page-header h1 { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center;
    padding: 10px 14px; overflow-x: auto; overflow-y: visible;
  }
  .sidebar-brand { padding: 0 14px 0 0; order: 1; }
  .sidebar-tenant-box {
    order: 2;
    border-bottom: none; border-left: 1px solid var(--border);
    margin-bottom: 0; margin-left: 10px; padding-bottom: 0; padding-left: 14px;
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  }
  .sidebar-links { flex-direction: row; flex: none; order: 3; }
  .sidebar-link { white-space: nowrap; }
  .sidebar-footer {
    order: 4;
    border-top: none; border-left: 1px solid var(--border);
    margin-top: 0; margin-left: 10px; padding-top: 0; padding-left: 14px;
    display: flex; align-items: center; flex-shrink: 0;
  }
  .sidebar-user { margin-bottom: 0; white-space: nowrap; }
  .sidebar-user-sub { display: inline; margin-left: 4px; }
  .sidebar-tenant-label { display: none; }
}
