/* ═══════════════════════════════════════════════════════════════════════
   GenesisOS — Design System (identidade Genesis: dark + Sora + verde-limão)
   FONTE ÚNICA do shell/tema. Layout e posição dos elementos INALTERADOS —
   só a "pele" (cores, tipografia) veste a identidade do Painel Genesis.
   ═══════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&display=swap');

:root {
  --background: #070707;                 /* fundo escuro Genesis */
  --nav: #0c0c0c;                        /* sidebar (levemente destacada do fundo) */
  --surface: rgba(255, 255, 255, 0.05);  /* tiles/hover suave */
  --border: rgba(255, 255, 255, 0.09);   /* hairline */
  --text-1: #F9F9F9;                     /* texto principal */
  --text-2: #a8a8a4;
  --text-3: #7a7a76;
  --text-4: #555551;
  --primary: #9FEC14;                    /* verde-limão Genesis — cor de marca/ação */
  --primary-hover: #b2f041;
  --primary-ink: #070707;                /* texto sobre o verde (verde é claro) */
  --success: #35c46a;
  --danger: #ff6b6b;
  --hover: rgba(255, 255, 255, 0.05);
  --active: rgba(255, 255, 255, 0.08);
}

/* ─── Tema CLARO (opt-in via <html class="light">). Especificidade html.light
   (0,1,1) vence os :root locais das páginas (0,1,0), então alterna tudo que
   usa tokens. Dark é o padrão (sem a classe). ─── */
html.light {
  --background: #ffffff;
  --nav: #f7f7f5;
  --surface: #f1f1ef;
  --border: #e9e9e7;
  --text-1: #37352f;
  --text-2: #787774;
  --text-3: #9b9a97;
  --text-4: #c7c7c4;
  --primary: #7fbf10;                    /* verde Genesis um tom mais fechado p/ contraste no branco */
  --primary-hover: #6ea80d;
  --primary-ink: #ffffff;
  --success: #28a465;
  --danger: #eb5757;
  --hover: rgba(0, 0, 0, 0.04);
  --active: rgba(0, 0, 0, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body.app-page {
  font-family: 'Sora', system-ui, sans-serif;
  background: var(--background);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}
body.app-page a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* ─── Shell ─── */
.app-page .app { display: flex; height: 100vh; }

/* ─── Sidebar (248px, #F7F7F5) — retrátil como o chat ─── */
.app-page aside {
  width: 248px; flex: none; height: 100%; overflow: hidden;
  transition: width 0.18s ease;
}
.app-page aside.gos-collapsed { width: 0; }
.side-inner {
  width: 248px; min-width: 248px; height: 100%;
  background: var(--nav); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.side-header {
  height: 45px; flex: none; display: flex; align-items: center;
  padding: 0 8px 0 10px; gap: 8px;
}
.side-header .brand { display: flex; align-items: center; gap: 8px; padding: 4px; min-width: 0; }
.logo-tile {
  display: grid; place-items: center; flex: none;
}
.logo-tile svg { display: block; }
.logo-tile img { height: 21px; width: auto; display: block; }

/* Botão de recolher (aparece no hover da sidebar) + trilho de abrir */
.side-collapse {
  margin-left: auto; flex: none; width: 26px; height: 26px; border: 0;
  background: none; color: var(--text-3); border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  opacity: 0; transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.app-page aside:hover .side-collapse { opacity: 1; }
.side-collapse:hover { background: var(--active); color: var(--text-1); }
.gos-open-rail {
  position: fixed; top: 9px; left: 9px; z-index: 50;
  width: 32px; height: 32px; border: 1px solid var(--border); background: var(--background);
  color: var(--text-2); border-radius: 6px; cursor: pointer;
  display: none; align-items: center; justify-content: center; font-size: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.gos-open-rail:hover { background: var(--hover); color: var(--text-1); }
.app-page aside.gos-collapsed ~ .gos-open-rail { display: flex; }
.brand span { font-size: 14px; font-weight: 600; color: var(--text-1); white-space: nowrap; }
.brand span b { font-weight: 800; }

.side-nav { flex: 1; overflow-y: auto; padding: 6px 8px; }
.side-section { margin-top: 16px; }
.side-section:first-child { margin-top: 0; }
.side-section > p {
  padding: 0 8px; margin-bottom: 4px;
  font-size: 11px; font-weight: 500; color: var(--text-3); user-select: none;
}
.side-items { display: flex; flex-direction: column; gap: 1px; }
.side-item {
  display: flex; align-items: center; height: 30px; padding: 0 8px; gap: 10px;
  border-radius: 6px; color: var(--text-2); transition: background 0.12s ease;
}
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--active); color: var(--text-1); font-weight: 500; }
.side-item i { font-size: 15px; flex: none; color: var(--text-3); }
.side-item.active i { color: var(--text-1); }
.side-item span { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item .ext { margin-left: auto; font-size: 11px; color: var(--text-4); }

.side-footer { flex: none; border-top: 1px solid var(--border); padding: 6px; }
.side-user {
  display: flex; align-items: center; gap: 8px; padding: 6px;
  border-radius: 6px; transition: background 0.12s ease;
}
.side-user:hover { background: var(--hover); }
.avatar-wrap { position: relative; flex: none; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--active); color: var(--text-1);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}
.presence {
  width: 10px; height: 10px; border-radius: 50%; background: var(--success);
  border: 2px solid var(--nav); position: absolute; bottom: -2px; right: -2px;
}
.side-user p { font-size: 13px; font-weight: 500; color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user button {
  font-family: inherit; width: 28px; height: 28px; border-radius: 6px; border: 0;
  background: none; color: var(--text-3); cursor: pointer; font-size: 15px;
  display: grid; place-items: center; flex: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.side-user button:hover { background: var(--active); color: var(--text-1); }

/* ─── Conteúdo ─── */
.app-page .content { flex: 1; overflow-y: auto; }
.app-page .page { max-width: 820px; margin: 0 auto; padding: 48px 40px 96px; }
.app-page .page.wide { max-width: 1100px; }

.gos-hero { margin-bottom: 26px; }
.gos-hero h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-1); }
.gos-hero p { font-size: 14px; color: var(--text-3); margin-top: 4px; }

/* ─── Cards / tabelas / forms flat ─── */
.gos-card {
  background: var(--background); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px;
}
.gos-card + .gos-card { margin-top: 14px; }
.gos-card h2, .gos-section-title {
  font-size: 15px; font-weight: 600; color: var(--text-1);
  letter-spacing: -0.01em; margin-bottom: 14px;
}

.gos-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.gos-table th {
  text-align: left; font-weight: 500; color: var(--text-3);
  font-size: 12px; padding: 8px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.gos-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-1); vertical-align: middle;
}
.gos-table tbody tr:last-child td, .gos-table tr:last-child td { border-bottom: 0; }
.gos-table tbody tr:hover { background: var(--hover); }

/* ─── Form ─── */
.gos-field { margin-bottom: 16px; }
.gos-field label,
.gos-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.gos-input, .gos-select, .gos-textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text-1);
  background: var(--background); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 12px; height: 38px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.gos-textarea { height: auto; padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.5; }
.gos-input:focus, .gos-select:focus, .gos-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(159,236,20,0.22);
}
.gos-input::placeholder, .gos-textarea::placeholder { color: var(--text-4); }
.gos-help { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ─── Botões ─── */
.gos-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  height: 38px; padding: 0 16px; border-radius: 6px; border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
  white-space: nowrap;
}
.gos-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Primário = ink (preto Notion). A Genesis não é azul; azul fica só p/ link. */
.gos-btn-primary { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.gos-btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.gos-btn-ghost { background: var(--background); color: var(--text-1); border-color: var(--border); }
.gos-btn-ghost:hover:not(:disabled) { background: var(--hover); }
.gos-btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }

/* ─── Badges ─── */
.gos-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
}
.gos-badge.ok { background: rgba(53,196,106,0.12); color: #4fd88a; border-color: rgba(53,196,106,0.3); }
.gos-badge.warn { background: rgba(245,184,65,0.14); color: #F5B841; border-color: rgba(245,184,65,0.3); }
.gos-badge.danger { background: rgba(255,107,107,0.12); color: #ff8f8f; border-color: rgba(255,107,107,0.3); }
.gos-badge.info { background: rgba(159,236,20,0.12); color: #9FEC14; border-color: rgba(159,236,20,0.3); }

/* ─── Alerts ─── */
.gos-alert {
  display: none; align-items: flex-start; gap: 8px;
  font-size: 13.5px; line-height: 1.45; padding: 11px 14px;
  border-radius: 6px; margin-bottom: 16px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-1);
}
.gos-alert.show { display: flex; }
.gos-alert.error { background: rgba(255,107,107,0.09); border-color: rgba(255,107,107,0.3); color: #ff8f8f; }
.gos-alert.success { background: rgba(53,196,106,0.1); border-color: rgba(53,196,106,0.3); color: #4fd88a; }

/* ─── Loader inline p/ botão ─── */
.gos-spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: gos-rot 0.7s linear infinite; display: none;
}
.gos-btn.loading .gos-spin { display: inline-block; }
.gos-btn.loading .gos-btn-label { opacity: 0.7; }
@keyframes gos-rot { to { transform: rotate(360deg); } }

/* ─── KPI cards (métrica: label + número grande + estado) ───
   Reutilizável em vendas, home, admin. Estado via classe: .ok .warn .danger. */
.gos-kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.gos-kpi {
  background: var(--nav); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.gos-kpi .label {
  font-size: 12px; font-weight: 500; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
}
.gos-kpi .valor { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-1); line-height: 1.1; }
.gos-kpi .sub { font-size: 12px; color: var(--text-3); }
/* estados: pinta o número e uma faixa à esquerda */
.gos-kpi.ok { border-left: 3px solid var(--success); }
.gos-kpi.ok .valor { color: var(--success); }
.gos-kpi.warn { border-left: 3px solid #F5B841; }
.gos-kpi.warn .valor { color: #F5B841; }
.gos-kpi.danger { border-left: 3px solid var(--danger); }
.gos-kpi.danger .valor { color: var(--danger); }
.gos-kpi.primary { border-left: 3px solid var(--primary); }
.gos-kpi.primary .valor { color: var(--primary); }

/* ─── Barra flutuante de ação em lote (seleção múltipla) ───
   Reutilizável em prospecção, contratos, admin. Some quando 0 selecionados. */
.gos-bulkbar {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 24px);
  z-index: 60; display: flex; align-items: center; gap: 14px;
  background: var(--nav); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px 10px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.16s ease, transform 0.16s ease;
}
.gos-bulkbar.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.gos-bulkbar .cont { font-size: 13.5px; color: var(--text-1); font-weight: 500; white-space: nowrap; }
.gos-bulkbar .cont b { color: var(--primary); font-weight: 700; }
.gos-bulkbar .sep { width: 1px; height: 22px; background: var(--border); }
.gos-bulkbar button { font-family: inherit; }

/* ─── Checkbox custom (nunca o nativo do browser) ───
   Caixa arredondada que fica verde com tick preto quando marcada. */
.gos-check {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 18px; height: 18px; flex: none; cursor: pointer;
  border: 1.5px solid var(--text-4); border-radius: 5px; background: var(--surface);
  display: inline-grid; place-items: center;
  transition: background .12s ease, border-color .12s ease;
}
.gos-check:hover { border-color: var(--primary); }
.gos-check:checked { background: var(--primary); border-color: var(--primary); }
.gos-check:checked::after {
  content: ''; width: 5px; height: 9px; margin-top: -1px;
  border: solid #070707; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ─── Tabela avançada: cabeçalho fixo + 1ª coluna congelável ───
   Envolva <table> em <div class="gos-table-wrap"> (o scroll acontece aqui).
   O thead "gruda" no topo ao rolar; com .frozen, a 1ª coluna fica fixa ao
   rolar na horizontal. Reutilizável em prospecção, contratos, admin. */
.gos-table-wrap {
  overflow: auto; max-height: calc(100vh - 220px);
  border: 1px solid var(--border); border-radius: 10px; background: var(--nav);
}
.gos-table-wrap table { width: 100%; border-collapse: collapse; }
.gos-table-wrap thead th {
  position: sticky; top: 0; z-index: 2; background: var(--nav);
  box-shadow: inset 0 -1px 0 var(--border);
}
/* congela a 1ª coluna (ex.: nome) ao rolar horizontalmente */
.gos-table-wrap.frozen tbody td:first-child,
.gos-table-wrap.frozen thead th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--nav);
  box-shadow: inset -1px 0 0 var(--border);
}
.gos-table-wrap.frozen thead th:first-child { z-index: 3; }

/* ═══ Login (sem sidebar) ═══ */
body.gos-auth {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--background); color: var(--text-1);
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  font-size: 14px;
}
.gos-auth-box { width: 100%; max-width: 360px; }
.gos-auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 30px; }
.gos-auth-brand .logo-tile { width: 40px; height: 40px; display: grid; place-items: center; }
.gos-auth-brand .logo-tile img { height: 38px; width: auto; filter: none; }
.gos-auth-brand h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; text-align: center; }
.gos-auth-brand p { font-size: 14px; color: var(--text-3); margin-top: 2px; text-align: center; }
.gos-auth-box form { display: flex; flex-direction: column; gap: 16px; }
.gos-auth-box .gos-btn-primary { width: 100%; height: 42px; font-size: 15px; }
.gos-auth-foot { text-align: center; font-size: 12px; color: var(--text-4); margin-top: 34px; }

/* A barra de funil (fluxo-barra.js) já traz o próprio estilo Notion light —
   sem override aqui, pra não brigar com o componente. */
