/* Carga manual — Pipeline BI (DATA)
   Estilo "framed sheet" (tasteskill, .taste-skill/direction.json): moldura em L (sidebar + barra de
   48px) num cinza puxado ao vermelho DATA, a tela numa folha branca recuada 8px da direita e de baixo,
   borda 1px, cantos 16px, sem sombra. O vermelho DATA fica no dado principal (a carga rodando, o
   progresso), na aba ativa e no único botão primário.

   Grade da folha a 1440px: 1440 − 228 (sidebar) − 8 (recuo) − 2 (borda) − 48 (padding) = 1154px;
   12 colunas de 81,5px + 11 × 16px = 1154. Fila 5 col (471,5) + 16 + log 7 col (666,5) = 1154. */

@font-face { font-family: "Montserrat"; src: url("fonts/Montserrat-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("fonts/Montserrat-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("fonts/Montserrat-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --frame: #f7f3f3;           /* moldura: um passo do vermelho DATA, quase neutro */
  --surface: #ffffff;         /* a folha */
  --raised: #faf7f7;          /* poço interno (log), hover de linha */
  --active: #efe9e9;          /* item ativo da sidebar */
  --border: #ebe6e6;          /* borda da folha e dos painéis */
  --rule: #f3efef;            /* linhas entre registros */
  --control: #d6cfcf;         /* campos e botões contornados */
  --text: #161212;
  --muted: #5e5757;           /* 7:1 no branco */
  --faint: #6d6666;           /* 5,6:1 no branco */
  --accent: #b31816;          /* vermelho DATA */
  --accent-hover: #961311;
  --accent-tint: #fbeceb;
  --done: #1f1b1b;            /* dataset concluído no trilho */
  --pending: #e8e2e2;
  --positive: #247b50; --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-neutral-bg: #efe9e9; --pill-neutral-ink: #3d3535;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e;

  --font: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace /* taste-skill-ignore: só no log, saída literal de máquina */, "Cascadia Mono", Consolas, monospace;
  --fs-title: 24px; --fs-section: 16px; --fs-figure: 30px; --fs-body: 14px; --fs-small: 12px;

  --sidebar: 228px; --topbar: 48px; --inset: 8px; --pad: 24px; --gap: 16px; --card-pad: 20px;
  --radius-sheet: 16px; --radius-card: 10px; --radius-control: 8px;
  --control-h: 34px;
  --t: 150ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--frame); color: var(--text); font: 400 var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- moldura ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-rows: var(--topbar) minmax(0, 1fr); min-height: 100svh; }
.sidebar { grid-row: 1 / 3; position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding: 14px 12px 16px; }
.marca { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px; margin-bottom: 18px; }
.marca img { height: 18px; width: auto; }
.marca span { font-weight: 600; font-size: 14px; }
.nav-label { margin: 0 8px 6px; font-size: var(--fs-small); color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); text-align: left; cursor: pointer; transition: background-color var(--t), color var(--t); }
.nav-item svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 600; }
.sidebar .pe { margin-top: auto; padding: 12px 8px 0; display: grid; gap: 2px; }
.sidebar .pe .nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .pe .perfil { font-size: var(--fs-small); color: var(--faint); }
.sidebar .pe button { justify-self: start; margin-top: 8px; padding: 0; border: 0; background: none; color: var(--muted); font-size: var(--fs-small); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 0 calc(var(--inset) + 16px) 0 4px; color: var(--muted); }
.topbar .escopo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .escopo b { color: var(--text); font-weight: 600; }
.topbar .destino { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-small); }
.topbar .destino span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.menu-btn { display: none; }

.folha { min-width: 0; margin: 0 var(--inset) var(--inset) 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); padding: var(--pad); }

/* ---------- título ---------- */
.titulo { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 24px; }
.titulo .linha-h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.titulo h1 { font-size: var(--fs-title); line-height: 30px; font-weight: 700; letter-spacing: -0.01em; }
.titulo .sub { margin-top: 6px; color: var(--muted); max-width: 70ch; }
.acoes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); padding: 0 14px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color var(--t), border-color var(--t), transform 120ms; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primario:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { cursor: not-allowed; transform: none; background: var(--raised); border-color: var(--border); color: var(--faint); }
.link { padding: 0; border: 0; background: none; color: var(--text); font-weight: 600; cursor: pointer; text-underline-offset: 3px; }
.link:hover { text-decoration: underline; }
.link-perigo { color: var(--pill-negative-ink); }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.campo { display: grid; gap: 8px; }
.campo label { font-weight: 600; }
.campo input, .campo select, select.inline { height: 38px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); min-width: 0; }
select.inline { height: 32px; padding: 0 8px; }
.campo .ajuda { color: var(--faint); font-size: var(--fs-small); }

.pill { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-small); font-weight: 600; white-space: nowrap; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pill.ok { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.erro { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.rodando { background: var(--accent-tint); color: var(--accent); }
.pill.rodando::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulso 1.1s ease-in-out infinite; }
.pill.aviso { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
@keyframes pulso { 50% { opacity: .35; } }

/* ---------- painéis ---------- */
.painel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.painel + .painel { margin-top: var(--gap); }
.painel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.painel h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 700; }
.painel .meta { color: var(--faint); font-size: var(--fs-small); }

/* carga: a resposta da tela */
.carga-topo { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; }
.carga-resposta .figura { font-size: var(--fs-figure); line-height: 36px; font-weight: 700; letter-spacing: -0.01em; }
.carga-resposta .figura small { font-size: 16px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.carga-resposta .detalhe { margin-top: 6px; color: var(--muted); }
.carga-resposta .detalhe b { color: var(--text); font-weight: 600; }
.numeros { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(96px, auto); }
.numeros > div { padding: 0 20px; border-left: 1px solid var(--border); }
.numeros dt { font-size: var(--fs-small); color: var(--faint); }
.numeros dd { margin-top: 2px; font-size: 20px; line-height: 26px; font-weight: 600; text-align: left; }
.numeros dd.ruim { color: var(--pill-negative-ink); }
.barra { height: 8px; margin-top: 18px; border-radius: 999px; background: var(--pending); overflow: hidden; }
.barra > div { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.barra.parada > div { background: var(--done); }

/* trilho: os datasets na ordem real do pipeline */
.trilho-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin: 22px 0 8px; }
.trilho-head h3 { font-size: var(--fs-body); font-weight: 600; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-small); color: var(--muted); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 10px; height: 10px; border-radius: 2px; }
.trilho { display: grid; grid-template-columns: repeat(var(--n, 38), minmax(0, 1fr)); gap: 3px; }
.trilho li { height: 28px; border-radius: 3px; background: var(--pending); position: relative; }
.st-ok { background: var(--done) !important; }
.st-rodando { background: var(--accent) !important; animation: pulso 1.1s ease-in-out infinite; }
.st-erro { background: var(--pill-negative-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Cpath d='M-1 7 7-1' stroke='%23831c1e' stroke-width='1.6'/%3E%3C/svg%3E") repeat !important; outline: 1.5px solid var(--pill-negative-ink); outline-offset: -1.5px; }
.st-cancelado { background: var(--surface) !important; outline: 1.5px solid var(--control); outline-offset: -1.5px; }
.st-fora { background: var(--rule) !important; }
.trilho li:hover::after { content: attr(data-rotulo); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5; padding: 4px 8px; border-radius: 6px; background: var(--text); color: #fff; font-size: var(--fs-small); white-space: nowrap; pointer-events: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.carga-corpo { margin-top: 22px; }
/* fila como tabela: status | dataset (+ erro) | grupo | duração */
.fila-cab, .fila li { display: grid; grid-template-columns: 104px minmax(0, 1.4fr) minmax(0, 1fr) 96px 96px; align-items: center; gap: 16px; padding: 0 8px; }
.fila-cab { height: 32px; font-size: var(--fs-small); color: var(--faint); }
.fila { position: relative; max-height: 344px; overflow: auto; }
.fila li { min-height: 44px; padding-top: 6px; padding-bottom: 6px; border-top: 1px solid var(--rule); }
.fila .grupo-col { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .fim, .fila-cab .fim { color: var(--muted); text-align: right; }
.fila .nome small.grupo-sub { display: none; }
.fila li.vazio { display: block; }
.fila li:first-child { border-top: 0; }
.fila li.atual { background: var(--accent-tint); border-radius: 6px; }
.fila .nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .nome small { display: block; color: var(--faint); font-size: var(--fs-small); line-height: 16px; overflow: hidden; text-overflow: ellipsis; }
.fila .dur, .fila-cab .dur { color: var(--faint); font-size: var(--fs-small); text-align: right; }
.fila .pill { justify-self: start; }
.log { height: 344px; overflow: auto; padding: 12px 14px; border-radius: 8px; background: var(--raised); font: 12px/18px var(--mono); color: var(--text); white-space: pre-wrap; word-break: break-word; }
.log .painel-linha { color: var(--accent); font-weight: 600; }
.log .erro-linha { color: var(--pill-negative-ink); }
.log-cheio { height: calc(100svh - 230px); min-height: 360px; font-size: 13px; line-height: 20px; padding: 16px 20px; }
.nav-ponto { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--accent); animation: pulso 1.1s ease-in-out infinite; }
.sub-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.sub-h h3 { font-size: var(--fs-body); font-weight: 600; }
.sub-h h3 .meta { margin-left: 6px; font-weight: 400; }

/* seleção de datasets */
.grupos { columns: 3 300px; column-gap: 40px; }
.grupo { break-inside: avoid; margin-bottom: 18px; }
.grupo h3 { display: flex; align-items: center; gap: 10px; height: 30px; font-size: var(--fs-body); font-weight: 700; }
.grupo label.cab { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.ds { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 36px; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; transition: background-color var(--t); }
.ds:hover { background: var(--raised); }
.ds .rot { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds .quando { font-size: 13px; color: var(--faint); white-space: nowrap; }
.ds .quando.erro { color: var(--pill-negative-ink); font-weight: 600; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset:disabled .ds { cursor: default; }
fieldset:disabled .ds:hover { background: none; }

/* acessos */
.secao { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 32px; padding: 28px 0; border-top: 1px solid var(--border); }
.secao:first-of-type { border-top: 0; padding-top: 4px; }
.secao .lado h2 { font-size: var(--fs-section); font-weight: 700; }
.secao .lado p { margin-top: 6px; color: var(--muted); }
.form-acesso { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 16px; align-items: end; padding: 16px; border-radius: var(--radius-card); background: var(--raised); }
.perfis { display: grid; gap: 8px; margin-top: 14px; }
.perfis div { color: var(--muted); }
.perfis b { color: var(--text); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { height: 36px; text-align: left; font-size: var(--fs-small); font-weight: 400; color: var(--faint); }
td { height: 56px; padding: 6px 12px 6px 0; border-top: 1px solid var(--rule); vertical-align: middle; }
td small { display: block; color: var(--faint); font-size: var(--fs-small); line-height: 16px; }
td.acao, th.acao { text-align: right; padding-right: 0; }
.historico li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--rule); }
.historico li:first-child { border-top: 0; }
.historico .quando { color: var(--faint); font-size: var(--fs-small); white-space: nowrap; }

/* estados */
.vazio { padding: 12px 14px; border: 1px dashed var(--control); border-radius: 8px; color: var(--muted); }
.aviso-erro { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--gap); padding: 10px 14px; border-radius: 8px; background: var(--pill-negative-bg); color: var(--pill-negative-ink); font-weight: 600; }
.mensagem-erro { color: var(--pill-negative-ink); font-weight: 600; min-height: 20px; }

/* tela de entrada (login / sem acesso) */
.entrada { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.entrada-cartao { width: min(420px, 100%); padding: 36px 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); }
.entrada-cartao img { height: 28px; width: auto; }
.entrada-cartao h1 { margin-top: 28px; font-size: 22px; line-height: 28px; font-weight: 700; }
.entrada-cartao p { margin-top: 8px; color: var(--muted); }
.entrada-cartao .btn { width: 100%; height: 42px; margin-top: 24px; }
.entrada-cartao .rodape { margin-top: 24px; font-size: var(--fs-small); color: var(--faint); }

/* ---------- tablet e celular ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar) auto; }
  .sidebar { display: none; position: fixed; inset: 0; z-index: 20; height: 100svh; width: 100%; background: var(--frame); padding: 14px 16px 20px; }
  .sidebar.aberta { display: flex; }
  .btn.menu-btn { display: inline-flex; width: 40px; padding: 0; }
  .menu-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
  .topbar { padding: 0 16px; }
  .topbar .marca-curta { display: block; height: 14px; width: auto; }
  .folha { margin: 0; border-radius: 0; border-width: 1px 0 0; }
  .carga-topo { grid-template-columns: minmax(0, 1fr); }
  .numeros > div:first-child { border-left: 0; padding-left: 0; }
  .secao { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
@media (min-width: 1101px) { .topbar .marca-curta, .sidebar .fechar { display: none; } }
@media (max-width: 640px) {
  :root { --pad: 16px; --card-pad: 16px; }
  .topbar .destino { display: none; }
  .titulo .acoes { width: 100%; }
  .titulo .acoes .btn { flex: 1; height: 44px; }
  .numeros { grid-auto-flow: row; grid-template-columns: 1fr 1fr; gap: 12px 0; }
  .numeros > div { padding: 0 0 0 12px; }
  .numeros > div:nth-child(odd) { border-left: 0; padding-left: 0; }
  .trilho li { height: 22px; }
  .trilho { gap: 2px; }
  .log-cheio { height: calc(100svh - 260px); }
  .fila-cab { display: none; }
  .fila li { grid-template-columns: 88px minmax(0, 1fr) auto; gap: 12px; padding: 6px 4px; }
  .fila .grupo-col, .fila .fim { display: none; }
  .fila .nome small.grupo-sub { display: block; }
  .form-acesso { grid-template-columns: minmax(0, 1fr); }
  .form-acesso .btn { height: 44px; }
  .tabela-acessos thead { display: none; }
  .tabela-acessos tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--rule); }
  .tabela-acessos td { height: auto; padding: 0; border: 0; }
  .tabela-acessos td.alterado { grid-column: 1; }
  .ds { min-height: 44px; }
  .ds .rot, .fila .nome, .fila .nome small { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
