feat: SSO from GTI Gerenciador and the Gerenciador visual identity

Collaborators logged into GTI Gerenciador open GTI Fiscal without a
second password. The panel signs a 60 s JWT (Ed25519; the Hub holds only
the public key); the Hub checks signature, iss/aud/exp/nbf, maximum
lifetime, nonce against a one-time state cookie set when the flow starts
at GET /login (login-CSRF protection) and a single-use jti
(sso_used_assertions). Collaborators are provisioned in admin_users with
auth_source=GTI_GERENCIADOR and no password; a CHECK constraint makes a
passwordless local account or a federated account with a password
impossible (migration 0021). Sessions last FEDERATED_SESSION_SECONDS
(1 h) and are renewed silently through the panel.

The local admin stays as break-glass at /login/local, audited. Logout ends
only the Hub session. Every SSO success/rejection (stable reason code),
logout and local login is audited with the real client IP, never the
token. verify_password now fails closed on a missing hash instead of
raising.

Visual identity: gti-theme.css is a verbatim copy of the panel's
design system (tokens, sidebar, light/dark theme) plus its tema.js,
sidebar.js and logo; control-panel.css keeps only Hub components, all
colours from the panel tokens. Page structure and features unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gti
2026-09-23 12:21:26 -03:00
co-authored by Claude Opus 5.5
parent 91a2dda969
commit 64d3fc56e2
21 changed files with 1290 additions and 122 deletions
+112 -96
View File
@@ -1,114 +1,135 @@
/* GTI Fiscal — componentes específicos do Fiscal sobre o design system do
GTI Gerenciador (gti-theme.css, carregado antes). Nenhuma cor própria:
tudo vem dos tokens --cor-* do Gerenciador, inclusive no tema escuro. */
/* Aliases usados pelos templates do Fiscal -> tokens do Gerenciador */
:root {
--ink: #172126;
--muted: #5f7077;
--paper: #f5f7f6;
--card: #ffffff;
--line: #d5e1dd;
--accent: #0b6f67;
--accent-soft: #dff1ec;
--danger: #a83232;
--warn: #8b5a12;
--shadow: 0 10px 30px #183b3210;
--ink: var(--cor-texto);
--muted: var(--cor-texto-secundario);
--paper: var(--cor-fundo);
--card: var(--cor-superficie);
--line: var(--cor-borda);
--accent: var(--cor-acento-texto);
--accent-soft: var(--cor-acento-suave);
--danger: var(--cor-perigo);
--warn: var(--cor-aviso);
--shadow: var(--sombra-card);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, sans-serif; }
a { color: var(--accent); }
.topbar { min-height: 68px; background: #112c2b; color: #f5fffb; display: flex; align-items: center; padding: 0 clamp(18px, 4vw, 64px); gap: 42px; }
.brand { font-weight: 900; letter-spacing: .1em; color: #fff; text-decoration: none; font-size: 17px; }
.brand span { color: #8ed6bd; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 22px; flex: 1; }
.topbar nav a { color: #c2d9d2; text-decoration: none; }
.topbar nav a:hover, .topbar nav a:focus-visible { color: #fff; }
.ghost, button { cursor: pointer; }
.ghost { background: transparent; border: 1px solid #ffffff66; color: #fff; padding: 7px 13px; border-radius: 8px; }
.shell { max-width: 1440px; margin: 0 auto; padding: 38px clamp(18px, 4vw, 64px) 70px; }
.page-heading, .detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 26px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(28px, 3vw, 42px); line-height: 1.05; margin-bottom: 8px; letter-spacing: -.04em; }
h2 { font-size: 17px; margin-bottom: 16px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; margin-bottom: 9px; }
.muted, small { color: var(--muted); }
small { display: block; font-size: 12px; }
.live-dot { color: var(--accent); font-size: 12px; white-space: nowrap; }
/* ---------- layout: mesma sidebar do Gerenciador, conteúdo um pouco mais largo ---------- */
.conteudo-fiscal { max-width: 1280px; }
.sidebar-nav a.sidebar-voltar { color: var(--cor-texto-secundario); font-size: 0.9rem; }
.sidebar-nav a.sidebar-voltar:hover { color: var(--cor-texto); }
.sidebar-secao { padding: 14px 12px 4px; font-size: 0.72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--cor-texto-secundario); }
.sidebar.recolhida .sidebar-secao { display: none; }
/* ---------- tipografia de página ---------- */
.page-heading, .detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 20px; }
.page-heading h1, .detail-head h1 { margin-bottom: 4px; }
p { margin-top: 0; }
.eyebrow { color: var(--cor-acento-texto); font-size: 0.72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 6px; }
.muted, small { color: var(--cor-texto-secundario); }
small { display: block; font-size: 0.78rem; }
.live-dot { color: var(--cor-sucesso); font-size: 0.8rem; white-space: nowrap; }
/* ---------- cartões (mesmo visual de .cartao do Gerenciador) ---------- */
.metric, .panel { background: var(--cor-superficie); border: 1px solid var(--cor-borda); box-shadow: var(--sombra-card); border-radius: 12px; }
.panel { padding: 20px; margin-bottom: 20px; }
.panel h2 { font-size: 1.05rem; margin: 0 0 12px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-title h2 { margin-bottom: 0; }
.panel-title a { font-size: 0.85rem; }
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
.cards.compact { grid-template-columns: repeat(4, 1fr); }
.metric, .panel { background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 14px; }
.metric { padding: 17px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 29px; display: block; margin-top: 8px; letter-spacing: -.04em; }
.metric { padding: 16px; }
.metric span { color: var(--cor-texto-secundario); font-size: 0.8rem; }
.metric strong { font-size: 1.75rem; display: block; margin-top: 6px; }
.metric-inline strong { display: inline; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.panel { padding: 22px; margin-bottom: 20px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-title h2 { margin-bottom: 0; }
.panel-title a { color: var(--accent); font-size: 12px; }
.panel-title a.secondary { color: #fff; font-size: inherit; }
.split .panel { margin-bottom: 0; }
.coverage { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.coverage div { border-left: 3px solid var(--accent-soft); padding-left: 12px; }
.coverage strong { display: block; font-size: 23px; }
.coverage span { color: var(--muted); font-size: 12px; }
.coverage-status { margin: 16px 0 0; color: var(--accent); font-size: 12px; font-weight: 700; }
.registry-summary { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.coverage div { border-left: 3px solid var(--cor-acento); padding-left: 12px; }
.coverage strong { display: block; font-size: 1.4rem; }
.coverage span { color: var(--cor-texto-secundario); font-size: 0.78rem; }
.coverage-status { margin: 16px 0 0; color: var(--cor-sucesso); font-size: 0.8rem; font-weight: 700; }
.registry-summary { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--cor-borda); color: var(--cor-texto-secundario); font-size: 0.8rem; }
.registry-summary a { text-decoration: none; }
.bar-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 8px 0; }
.bar-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--cor-borda); padding: 8px 0; }
.bar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 24px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 8px; margin: 0 -8px; border-bottom: 1px solid var(--cor-borda); border-radius: 8px; text-decoration: none; color: inherit; transition: background var(--transicao); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #f7fbf9; }
.empty-state { color: var(--muted); border: 1px dashed var(--line); padding: 18px; margin: 0; }
.badge, .severity { display: inline-flex; align-items: center; border: 1px solid currentColor; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-style: normal; font-weight: 800; white-space: nowrap; }
.badge.large { padding: 7px 12px; }
.list-row:hover { background: var(--cor-superficie-alt); }
.empty-state { color: var(--cor-texto-secundario); border: 1px dashed var(--cor-borda); border-radius: 8px; padding: 18px; margin: 0; }
/* ---------- badges: mesma forma do .badge do Gerenciador, cores semânticas dos tokens ---------- */
.badge, .severity { display: inline-flex; align-items: center; border: 0; border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; font-style: normal; font-weight: 600; white-space: nowrap; background: var(--cor-superficie-alt); color: var(--cor-texto-secundario); }
.badge.large { padding: 6px 12px; }
.badge-stack { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.online, .fiscal-complete, .status-completed { color: #176646; background: #e5f5eb; }
.degraded, .warning, .fiscal-incomplete, .status-pending, .status-running, .priority-high { color: var(--warn); background: #fff1d5; }
.offline, .unknown { color: #53656c; background: #e9eef0; }
.failed, .priority-critical, .status-failed { color: var(--danger); background: #fde7e7; }
.blocked, .priority-normal { color: #6d4c1c; background: #fff3d8; }
.priority-low { color: #53656c; background: #e9eef0; }
.fiscal-blocked { color: #7d3c13; background: #ffead6; }
.online, .fiscal-complete, .status-completed, .info { background: var(--cor-sucesso-fundo); color: var(--cor-sucesso); }
.degraded, .warning, .fiscal-incomplete, .status-pending, .status-running, .priority-high { background: var(--cor-aviso-fundo); color: var(--cor-aviso); }
.offline, .unknown, .priority-low { background: var(--cor-superficie-alt); color: var(--cor-texto-secundario); }
.failed, .error.badge, .priority-critical, .status-failed, .critical { background: var(--cor-perigo-fundo); color: var(--cor-perigo); }
.blocked, .priority-normal, .fiscal-blocked { background: var(--cor-acento-suave); color: var(--cor-acento-texto); }
/* ---------- formulários e botões (padrão do Gerenciador) ---------- */
.conteudo-fiscal button { margin-top: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.filters label { color: var(--muted); display: grid; gap: 4px; font-size: 12px; font-weight: 700; }
.filters input, .filters select, .filters textarea, input, select, textarea { border: 1px solid #b8c9c4; background: #fff; border-radius: 7px; color: var(--ink); font: inherit; padding: 8px 10px; min-height: 38px; }
.filters input, .filters select { min-width: 150px; }
.filters label { color: var(--cor-texto-secundario); display: grid; gap: 4px; font-size: 0.8rem; font-weight: 600; margin: 0; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters button { align-self: end; }
.secondary, button:not(.ghost) { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 8px 13px; border-radius: 7px; text-decoration: none; font: inherit; }
.secondary:hover, button:not(.ghost):hover { background: #095a54; }
textarea { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--cor-borda); background: var(--cor-fundo); color: var(--cor-texto); font: inherit; width: 100%; }
/* Como no Gerenciador: <button> é a ação principal (laranja, gti-theme.css);
link com cara de botão (a.secondary ~ a.botao) tem só contorno. */
a.secondary { display: inline-block; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--cor-borda); background: transparent; color: var(--cor-texto); font-weight: 400; text-decoration: none; }
a.secondary:hover { border-color: var(--cor-acento); color: var(--cor-acento); }
.blocker-filters label { flex: 1 1 170px; }
.compact-filters { margin-top: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 960px; }
caption { text-align: left; font-size: 17px; font-weight: 800; margin-bottom: 12px; }
th { color: var(--muted); font-size: 11px; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 10px; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td a { text-decoration: none; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 4px 0 22px; color: var(--muted); }
.pagination a { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 10px; text-decoration: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 13px; text-decoration: none; color: var(--muted); }
.tabs a.active { color: var(--accent); border-bottom: 3px solid var(--accent); font-weight: 800; }
.facts { display: grid; grid-template-columns: minmax(130px, .7fr) 1fr; gap: 10px 18px; margin: 0; }
.facts dt { color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.event-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.event-time { color: var(--muted); font-size: 12px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.login-card { width: min(100%, 420px); display: grid; gap: 10px; padding: 30px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.login-card .eyebrow, .login-card h1 { margin-bottom: 2px; }
.login-card label { margin-top: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid label { display: grid; gap: 5px; color: var(--muted); font-weight: 700; }
.form-grid label { display: grid; gap: 5px; color: var(--cor-texto-secundario); font-weight: 600; margin: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid select, .form-grid input, .form-grid textarea { width: 100%; }
.form-grid textarea { min-height: 100px; resize: vertical; }
.error, .error-text { color: var(--danger); }
.evidence { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.4 ui-monospace, monospace; }
.error, .error-text { color: var(--cor-perigo); }
.alert.error { padding: 10px 14px; border-radius: 8px; background: var(--cor-perigo-fundo); color: var(--cor-perigo); }
:focus-visible { outline: 3px solid #f1ae28; outline-offset: 2px; }
/* ---------- tabelas (mesmo cartão de .tabela-wrap do Gerenciador) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--cor-borda); border-radius: 12px; background: var(--cor-superficie); box-shadow: var(--sombra-card); }
.panel .table-wrap { box-shadow: none; }
/* Tabelas do Fiscal são largas: mantêm a largura mínima (rolagem horizontal no
.table-wrap) e só quebram palavras que não cabem — o overflow-wrap:anywhere
do tema quebraria nomes letra por letra em colunas estreitas. */
.conteudo-fiscal table { width: 100%; min-width: 960px; }
.conteudo-fiscal td { vertical-align: top; overflow-wrap: break-word; }
.conteudo-fiscal td a.secondary, .conteudo-fiscal td .badge { white-space: nowrap; }
caption { text-align: left; font-size: 1rem; font-weight: 700; padding: 14px 14px 4px; }
td a { text-decoration: none; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 12px 0 20px; color: var(--cor-texto-secundario); }
.pagination a { border: 1px solid var(--cor-borda); background: transparent; color: var(--cor-texto); border-radius: 8px; padding: 6px 12px; text-decoration: none; }
.pagination a:hover { border-color: var(--cor-acento); color: var(--cor-acento); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--cor-borda); }
.tabs a { padding: 9px 13px; text-decoration: none; color: var(--cor-texto-secundario); }
.tabs a.active { color: var(--cor-acento-texto); border-bottom: 3px solid var(--cor-acento); font-weight: 700; }
.facts { display: grid; grid-template-columns: minmax(130px, .7fr) 1fr; gap: 10px 18px; margin: 0; }
.facts dt { color: var(--cor-texto-secundario); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.event-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--cor-borda); }
.event-row:last-child { border-bottom: 0; }
.event-time { color: var(--cor-texto-secundario); font-size: 0.8rem; }
.evidence { white-space: pre-wrap; overflow-wrap: anywhere; font: 0.8rem/1.4 ui-monospace, monospace; }
/* ---------- páginas avulsas (acesso de emergência, erro de SSO, saída) — mesmo visual do login do Gerenciador ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at top, var(--cor-superficie-alt), var(--cor-fundo)); }
.login-card { width: 100%; max-width: 380px; text-align: center; margin: 0; }
.login-card form { text-align: left; }
.login-card form button[type="submit"] { width: 100%; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 12px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-subtitle { color: var(--cor-texto-secundario); font-size: 0.9rem; margin: 0 0 20px; }
.login-actions { display: grid; gap: 10px; margin-top: 16px; }
.login-actions a.botao { margin: 0; }
@media (max-width: 1100px) {
.cards { grid-template-columns: repeat(3, 1fr); }
@@ -117,9 +138,6 @@ td a { text-decoration: none; }
.badge-stack { justify-content: flex-start; }
}
@media (max-width: 768px) {
.topbar { align-items: flex-start; flex-wrap: wrap; gap: 14px 24px; padding-block: 16px; }
.topbar nav { order: 3; flex-basis: 100%; }
.shell { padding-top: 26px; }
.cards, .cards.compact, .split { grid-template-columns: 1fr 1fr; }
.coverage { grid-template-columns: repeat(2, 1fr); }
.form-grid { grid-template-columns: 1fr; }
@@ -129,6 +147,4 @@ td a { text-decoration: none; }
@media (max-width: 520px) {
.cards, .cards.compact, .split, .bar-grid { grid-template-columns: 1fr; }
.filters label, .filters input, .filters select, .filters button { width: 100%; }
.filters button { margin-top: 2px; }
.login-card { padding: 22px; }
}