@font-face {
  font-family: "Ethnocentric";
  src: local("Ethnocentric"), url("/fontes/Ethnocentric-Regular.otf") format("opentype");
  font-display: swap;
}

/* A paleta da casa, a mesma do INTENDENTE, do GUARDIÃO e do SENTINELA.
   `color-scheme: dark` faz o navegador pintar barra de rolagem e menu de
   `<select>` no esquema escuro. */
:root {
  color-scheme: dark;
  --bg: #0e0e0e;
  --rail: #151515;
  --card: #1a1a1a;
  --alto: #212121;
  --line: #2c2c2c;
  --line-forte: #3a3a3a;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --fraco: #6d6d6d;
  --ok: #4da36f;
  --no: #d06d52;
  --aviso: #c9a227;
  --brand: #ff6b00;
  --accent: #a05526;
  --accent-forte: #bf6832;
  --sans: "Ubuntu Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, "Noto Sans", sans-serif;
  --mono: "Noto Sans Mono", "Ubuntu Sans Mono", "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
  --marca: "Ethnocentric", "Eurostile", var(--sans);
  --raio: 7px;
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--fraco); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent-forte); outline-offset: 1px; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------- estrutura */

.app {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
}
.topo {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--rail);
}
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.conteudo { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.area { flex: 1; overflow: auto; min-height: 0; padding: 0 18px 40px; }

/* ------------------------------------------------------------------ marca */

.marca { display: flex; align-items: center; gap: 12px; }
.marca-logo { width: 54px; height: 54px; flex: 0 0 54px; object-fit: contain; }
.marca-nome {
  font-family: var(--marca);
  text-transform: uppercase;
  letter-spacing: 1.3px;
  font-size: 30px;
  line-height: 1.1;
  color: var(--brand);
}
.topo .marca-logo { width: 38px; height: 38px; flex-basis: 38px; }
.topo .marca-nome { font-size: 21px; }

.abas { display: flex; gap: 4px; margin-left: 12px; }
.aba {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 12px;
}
.aba:hover { background: var(--alto); color: var(--text); border-color: transparent; }
.aba[aria-current="true"] { background: var(--alto); color: var(--text); border-color: var(--line-forte); }

.eu { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.eu strong { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------- campos e botões */

.campo { display: flex; flex-direction: column; gap: 4px; }
.campo > span {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--fraco);
  font-weight: 600;
}
.campo.com-erro input, .campo.com-erro select { border-color: var(--no); }
.campo > span.erro-do-campo {
  color: var(--no);
  font-size: 11.5px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
select.estreito { width: auto; min-width: 260px; }

select, input[type="text"], input[type="search"], input[type="password"], input[type="date"],
input[type="number"], textarea {
  background-color: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-forte);
  border-radius: var(--raio);
  padding: 7px 9px;
  font-family: inherit;
  font-size: 12.5px;
  min-width: 0;
  width: 100%;
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%239a9a9a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 10px 6px;
  padding-right: 26px;
}
textarea { font-family: var(--mono); line-height: 1.5; resize: vertical; }

button {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--raio);
  padding: 7px 13px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
button:hover { background: var(--accent-forte); border-color: var(--accent-forte); }
button:disabled { opacity: .5; cursor: default; }
button.principal { background: var(--brand); border-color: var(--brand); font-weight: 600; }
button.principal:hover { background: #ff8126; border-color: #ff8126; }
button.secundario { background: transparent; border-color: var(--line-forte); color: var(--muted); }
button.secundario:hover { background: var(--alto); color: var(--text); }
button.perigo { background: transparent; border-color: var(--no); color: var(--no); }
button.perigo:hover { background: rgba(208, 109, 82, .12); }
button.leve { background: transparent; border-color: transparent; color: var(--muted); padding: 5px 8px; }
button.leve:hover { background: var(--alto); color: var(--text); }

/* O link que baixa tem cara de botão (um <button> dentro de <a> não é HTML válido). */
a.botao {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: var(--raio);
  padding: 7px 13px;
  font-size: 12.5px;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
}
a.botao.principal { background: var(--brand); border-color: var(--brand); font-weight: 600; }
a.botao.leve { background: transparent; border-color: transparent; color: var(--muted); padding: 5px 8px; }
a.botao.leve:hover { background: var(--alto); color: var(--text); }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--fraco); margin: 18px 0 6px; }

/* Os botões de um mesmo bloco ficam numa linha só, que quebra se faltar espaço. */
.botoes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ------------------------------------------------------------- a rail */

.rail-titulo {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--fraco);
  font-weight: 600;
  padding: 10px 8px 6px;
}
.item-rail {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: var(--raio);
}
.item-rail:hover { background: var(--alto); color: var(--text); border-color: transparent; border-left-color: transparent; }
.item-rail[aria-current="true"] { background: var(--alto); color: var(--text); border-left-color: var(--brand); }
.item-rail svg { flex: 0 0 15px; }

/* ----------------------------------------------------------- barra do conteúdo */

.barra {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  flex-wrap: wrap;
}
.trilha { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; min-width: 0; }
.trilha button { background: transparent; border-color: transparent; color: var(--muted); padding: 4px 6px; }
.trilha button:hover { color: var(--text); background: var(--alto); }
.trilha .atual { color: var(--text); font-weight: 600; padding: 4px 6px; }
.trilha .separador { color: var(--fraco); }
.barra .botoes { margin-left: auto; }
/* A busca larga da casa (como no INTENDENTE): 300px de base, 520 de teto. */
.busca-campo { flex: 1 1 300px; max-width: 520px; }
.busca-campo input { width: 100%; height: 32px; padding: 0 11px; font-size: 13px; }
.trecho { margin: 2px 0 0 30px; font-size: 12.5px; color: var(--muted); line-height: 1.45; max-width: 640px; }
.trecho mark { background: transparent; color: var(--brand); font-weight: 600; }
td.onde { color: var(--muted); font-size: 12.5px; }
td.pessoa { white-space: nowrap; }
.mais { display: flex; justify-content: center; padding: 14px 0; }

/* ------------------------------------------------------------------ tabela */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--fraco);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 58px;
  background: var(--bg);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.linha:hover td { background: #141414; }
td.numero, td.data { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
td.quem { color: var(--muted); white-space: nowrap; }
td.acoes { width: 1%; white-space: nowrap; }
td.acoes .botoes { flex-wrap: nowrap; justify-content: flex-end; gap: 2px; }
.nome-item {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0;
  font-size: 13.5px;
  text-align: left;
  white-space: normal;
}
.nome-item:hover { background: transparent; color: var(--brand); }
.nome-item svg { flex: 0 0 16px; color: var(--muted); }
.nome-item.pasta svg { color: var(--accent-forte); }
.vazio { color: var(--fraco); padding: 40px 0; text-align: center; }
.selo {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid var(--line-forte);
  color: var(--muted);
}
.selo.ok { border-color: var(--ok); color: var(--ok); }
.selo.aviso { border-color: var(--aviso); color: var(--aviso); }
.selo.no { border-color: var(--no); color: var(--no); }

/* --------------------------------------------------------------- envios */

.envios {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(380px, calc(100vw - 36px));
  background: var(--card);
  border: 1px solid var(--line-forte);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  z-index: 40;
  max-height: 50vh;
  overflow: auto;
}
.envios-topo { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.envio { padding: 9px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; }
.envio-nome { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.envio-nome span:last-child { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.barra-progresso { height: 4px; background: var(--alto); border-radius: 2px; overflow: hidden; }
.barra-progresso > div { height: 100%; background: var(--brand); transition: width .2s; }
.envio.feito .barra-progresso > div { background: var(--ok); }
.envio.falhou .barra-progresso > div { background: var(--no); }
.envio-recado { font-size: 11.5px; color: var(--no); }

/* -------------------------------------------------------------- janelas */

.janela-fundo {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  z-index: 50;
}
.janela {
  background: var(--card);
  border: 1px solid var(--line-forte);
  border-radius: 10px;
  width: min(560px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  animation: subir .16s ease-out;
}
.janela.larga { width: min(1100px, 100%); height: min(860px, 100%); }
.janela-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.janela-topo h2 { font-size: 15px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.janela-corpo { overflow: auto; padding: 16px 18px 20px; min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.janela-pe { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
/* Anima o deslocamento, nunca a opacidade: sem animação o conteúdo já está no lugar. */
@keyframes subir { from { transform: translateY(8px); } to { transform: none; } }

.previa { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #0a0a0a; border-radius: var(--raio); overflow: auto; }
.previa img, .previa video { max-width: 100%; max-height: 100%; }
.previa iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.previa pre { align-self: stretch; margin: 0; padding: 14px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; color: var(--text); width: 100%; }
.editor { flex: 1; min-height: 360px; }
.lista-simples { display: flex; flex-direction: column; }
.lista-simples > div { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lista-simples > div > .botoes { margin-left: auto; }
.recado { color: var(--muted); font-size: 12.5px; }
.passos { margin: 16px 0; padding-left: 20px; line-height: 1.9; }
.dados-do-sync { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
.dados-do-sync dt { color: var(--muted); }
.dados-do-sync dd { margin: 0; overflow-wrap: anywhere; user-select: all; }
.recado.erro { color: var(--no); }
.segredo { font-family: var(--mono); font-size: 15px; letter-spacing: 1.5px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-forte); border-radius: var(--raio); word-break: break-all; }
pre.script { margin: 0; padding: 12px; background: var(--bg); border: 1px solid var(--line-forte); border-radius: var(--raio); font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow: auto; }
.marcas { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.marcas label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.marcas input { accent-color: var(--accent); }

.filtros { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 14px 0 6px; align-items: end; }

/* ---------------------------------------------------------------- entrada */

.portao {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 80;
}
/* "PAIOL" na Ethnocentric a 30px mede cerca de 150px; com o logo de 54px e o
   espaço de 12px, cabe com folga nos 356px úteis do quadro. */
.portao-caixa {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line-forte);
  border-radius: 10px;
  padding: 34px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.portao-caixa .marca { margin-bottom: 10px; }
.portao-caixa input { background: var(--alto); padding: 11px 12px; font-size: 13.5px; }
.portao-caixa button { margin-top: 6px; width: 100%; padding: 11px 13px; font-size: 13.5px; font-weight: 600; }
.portao-recado { font-size: 12px; color: var(--fraco); min-height: 16px; }
.portao-recado.erro { color: var(--no); }
.codigo-aparelho { font-family: var(--mono); font-size: 22px; letter-spacing: 4px; color: var(--brand); text-align: center; padding: 8px 0; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
  .rail { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .rail-titulo { display: none; }
  .item-rail { width: auto; white-space: nowrap; }
  .topo { flex-wrap: wrap; }
  td.quem, th.quem { display: none; }
  td.quando, th.quando { display: none; }
  .trecho { margin-left: 0; }
}
@media (max-width: 468px) {
  .portao-caixa { padding: 26px 20px 22px; }
}

/* --------------------------------------------------- links (Fase 4) */
.linha-de-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ------------------------------------------- ver sem baixar (Fase 4) */
.previa.protegida { background: #2a2a2a; user-select: none; -webkit-user-select: none; }
.previa.protegida img { -webkit-user-drag: none; pointer-events: auto; }
.previa.protegida.ampliada { align-items: flex-start; justify-content: flex-start; }
.previa.protegida.ampliada img { max-width: none; max-height: none; }
@media print { .previa.protegida { display: none; } }
.previa.office { background: #fff; min-height: 70vh; }
.previa.office iframe { min-height: 70vh; }
.janela-pe [data-contador] { align-self: center; white-space: nowrap; }
