:root {
  /* Cinza-azulado em vez de preto puro: o contraste extremo cansa em tela
     que fica aberta o dia inteiro, e lê como terminal, não como console de
     operação. */
  --bg: #101418;
  --surface: #161b21;
  --surface-2: #1c222a;
  --surface-3: #222932;
  --border: #2a323c;
  --border-forte: #3a444f;

  --text: #dfe4ea;
  --muted: #8d97a4;
  --muted-2: #6b7683;

  /* Azul institucional, menos saturado que o padrão de terminal. */
  --accent: #3b7dd8;
  --accent-hover: #4a8ae5;

  /* Estados contidos: a cor informa sem gritar. */
  --ok: #4a9d6a;
  --warn: #b8862f;
  --err: #c9524f;

  --radius: 6px;
  --radius-lg: 8px;

  --sombra: 0 1px 2px rgba(0,0,0,.28);
  --sombra-alta: 0 10px 32px rgba(0,0,0,.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
code.block {
  display: block; padding: 9px 11px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  word-break: break-all; color: var(--muted);
}

h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 14px; font-weight: 600; }
h3.section {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 22px 0 12px; padding-top: 16px; border-top: 1px solid var(--border);
}
.muted { color: var(--muted); }

/* menu lateral */
:root { --lateral: 208px; }

.side {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--lateral);
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 30;
}
.side-marca {
  padding: 0 18px; height: 56px; display: flex; align-items: center;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14.5px;
  letter-spacing: -0.005em;
}
.side-marca a { color: var(--text); }
.side-marca a:hover { text-decoration: none; }
.side-marca span {
  color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 11px;
  padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px;
}

.side-menu { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; }
.side-menu a {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 13px; padding: 8px 10px;
  border-radius: var(--radius); transition: background .12s, color .12s;
}
.side-menu a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.side-menu a.ativo { color: var(--text); background: var(--surface-3); }
/* Barra à esquerda em vez de só o fundo: o realce por cor sozinho some para
   quem enxerga pouco contraste, e a posição do item ativo é a informação. */
.side-menu a.ativo { box-shadow: inset 2px 0 0 var(--accent); }
.side-menu svg { width: 16px; height: 16px; flex: 0 0 16px; stroke-linecap: round; stroke-linejoin: round; }

.side-rodape { padding: 12px 14px; border-top: 1px solid var(--border); }
.side-usuario {
  font-size: 11.5px; color: var(--muted-2); margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
button.link {
  background: none; border: none; color: var(--muted); font: inherit; font-size: 13px;
  cursor: pointer; padding: 0;
}
button.link:hover { color: var(--text); }

/* Barra superior das telas em tela cheia (logs, terminal), que não têm menu. */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 30;
}
.brand { font-weight: 600; letter-spacing: -0.005em; font-size: 15px; }
.brand a { color: var(--text); }
.brand a:hover { text-decoration: none; }
.brand span {
  color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px;
  padding: 2px 7px; border: 1px solid var(--border); border-radius: 4px;
}

/* Irmão e não filho: assim as telas sem menu (login, logs, terminal) usam o
   mesmo .wrap sem deslocamento, e nenhuma delas precisa fechar um wrapper. */
.side ~ .wrap { margin-left: var(--lateral); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px; }
.wrap.narrow { max-width: 780px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { font-size: 19px; }

/* cartões */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 18px; overflow: hidden;
  box-shadow: var(--sombra);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, var(--surface-2), var(--surface));
}
.card-body { padding: 20px; }

/* tabelas */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted-2); font-weight: 600; padding: 10px 20px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr { transition: background .1s; }

table.compact th, table.compact td { padding: 7px 10px; }
table.compact { border: 1px solid var(--border); border-radius: 6px; }
table.compact input[type=text] { padding: 5px 8px; }

.name { font-weight: 500; }
.sub { color: var(--muted); font-size: 12px; }
.sub code { font-size: 11px; }
.err-text { color: var(--err); max-width: 340px; }
.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 5px; }

/* estado */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; }
.dot.running { background: var(--ok); }
.dot.exited, .dot.dead { background: var(--err); }
.dot.created, .dot.paused, .dot.restarting { background: var(--warn); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 20px;
  background: var(--surface-3); border: 1px solid var(--border-forte); color: var(--muted);
  white-space: nowrap; letter-spacing: 0.01em;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto; opacity: .9;
}
.badge.healthy, .badge.success {
  color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent);
}
.badge.unhealthy, .badge.failed {
  color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent);
}
.badge.starting, .badge.running, .badge.rolled_back, .badge.pending {
  color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}

/* controles */
.actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

button, .btn {
  font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 6px 13px; border-radius: var(--radius);
  border: 1px solid var(--border-forte); background: var(--surface-3); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: border-color .12s, background .12s;
}
button:hover:not(:disabled), .btn:hover {
  background: #29313b; border-color: var(--muted-2); text-decoration: none;
}
/* Foco visível é requisito de acessibilidade: quem navega por teclado precisa
   enxergar onde está. */
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--err); border-color: var(--border-forte); }
button.danger:hover:not(:disabled) {
  border-color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent);
}

label {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--muted);
  margin-bottom: 6px; letter-spacing: 0.02em;
}
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border-radius: var(--radius);
  border: 1px solid var(--border-forte); background: var(--bg); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  line-height: 1.6; resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[readonly] { color: var(--muted); }

.field { margin-bottom: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 180px; }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.check label { margin: 0; color: var(--text); font-size: 13px; }
.check .hint { margin: 0; display: inline; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }

/* abas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: 8px 12px; font-size: 13px;
}
.tab:hover { border-color: transparent; color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* blocos informativos */
.kv { display: flex; gap: 28px; flex-wrap: wrap; }
.kv > div { display: flex; flex-direction: column; gap: 2px; }
.kv span.muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

ul.evidence { margin: 14px 0 0 18px; color: var(--muted); font-size: 12.5px; }
ul.evidence li { margin-bottom: 4px; }

.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty.small { padding: 22px 18px; font-size: 13px; }

.alert {
  padding: 12px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; border: 1px solid;
}
.alert:last-child { margin-bottom: 0; }
.alert.error {
  background: color-mix(in srgb, var(--err) 10%, transparent);
  border-color: color-mix(in srgb, var(--err) 35%, transparent);
}
.alert.warn {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
.alert.info {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

/* login e primeiro acesso */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px;
  box-shadow: var(--sombra-alta);
}
.auth-card h1 { margin-bottom: 6px; font-size: 20px; }

/* logs e terminal */
#logs, .log-block {
  background: #06070a; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; overflow-y: auto;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word;
}
#logs { height: calc(100vh - 150px); }
.log-block { max-height: 480px; color: #c9d1d9; }
#logs .line { color: #c9d1d9; }
#logs .meta { color: var(--muted); font-style: italic; }
#logs .err { color: var(--err); }

#term {
  background: #06070a; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; height: calc(100vh - 150px);
}

/* aviso flutuante */
.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 11px 15px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); opacity: 0; transform: translateY(8px);
  transition: opacity .15s, transform .15s; pointer-events: none; max-width: 420px; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: color-mix(in srgb, var(--err) 45%, transparent); }

@media (max-width: 860px) {
  /* Em tela estreita o menu vira uma faixa no topo: 208px de coluna fixa
     comeriam a metade útil da largura. */
  .side { position: static; width: auto; flex-direction: row; align-items: center;
          border-right: none; border-bottom: 1px solid var(--border); }
  .side-marca { border-bottom: none; padding-right: 14px; }
  .side-menu { flex-direction: row; padding: 0; gap: 0; overflow-x: auto; }
  .side-menu a { padding: 8px; border-radius: 0; }
  .side-menu a.ativo { box-shadow: inset 0 -2px 0 var(--accent); background: none; }
  .side-menu a span, .side-usuario { display: none; }
  .side-rodape { border-top: none; padding: 0 14px; }
  .side ~ .wrap { margin-left: 0; }
}

@media (max-width: 720px) {
  .page-head { flex-direction: column; }
  th:nth-child(n+4), td:nth-child(n+4) { display: none; }
}

/* Campo de busca com lista, para escolher entre muitos itens.
   Um select comum obrigaria a rolar dezenas de linhas procurando o nome. */
.combo { position: relative; }
.combo input { padding-right: 32px; }

.combo-limpar {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 2px 6px; cursor: pointer;
}
.combo-limpar:hover { color: var(--text); border: none; }

.combo-lista {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  max-height: 280px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.combo-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 11px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: var(--surface); }
.combo-item mark { background: none; color: var(--accent); font-weight: 600; }
.combo-tag {
  font-size: 11px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; flex: 0 0 auto;
}
.combo-vazio { padding: 14px 11px; color: var(--muted); font-size: 13px; text-align: center; }

/* Navegação de retorno nas telas em tela cheia. Texto em vez de símbolo:
   uma seta isolada não é lida por leitor de tela nem traduz bem. */
.voltar {
  color: var(--muted); font-size: 13px; font-weight: 500;
  padding: 5px 10px; border-radius: var(--radius);
  border: 1px solid var(--border-forte); margin-right: 12px;
}
.voltar:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* Etapas do deploy. Mostrar ONDE está importa: "implantando" sozinho não
   distingue um download de quatro minutos de um healthcheck travado. */
.etapas { display: flex; flex-direction: column; gap: 2px; }
.etapa {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; font-size: 13px; color: var(--muted-2);
}
.etapa .marca {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid var(--border-forte); background: transparent;
}
.etapa.feito { color: var(--muted); }
.etapa.feito .marca { background: var(--ok); border-color: var(--ok); }
.etapa.atual { color: var(--text); font-weight: 500; }
.etapa.atual .marca {
  background: var(--accent); border-color: var(--accent);
  animation: pulso 1.4s ease-in-out infinite;
}
@keyframes pulso {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); }
}

/* Resumo do histórico: uma linha, sem estourar a largura da tabela. */
td.resumo {
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Estado numa linha, para o que mudou ficar na primeira coisa que se lê. */
.linha-estado {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px;
}
.linha-estado strong { font-weight: 600; }

/* Ação destrutiva separada do resto: encostada na ação principal, é erro de
   clique esperando acontecer. */
.card.perigo { border-color: color-mix(in srgb, var(--err) 32%, var(--border)); }
.card.perigo .card-head h2 { color: var(--err); }

.sub .sep { color: var(--muted-2); margin: 0 6px; }
