/* Painel de status — estilos.
   Design system do hub (lucafchala.com): fundo #0d0c0a, âmbar #c08030,
   Cormorant Garamond + JetBrains Mono, tema claro e escuro. Layout no padrão
   das páginas de status da indústria: faixa-resumo, componentes com barras de
   histórico e disponibilidade, incidentes em linha do tempo. */

/* Fontes da própria origem (antes: Google Fonts). Cada visita ao painel
   entregava ao Google o IP e o navegador do visitante, e o fotos já tinha
   deixado de fazer isso (#131 do fotos) pela mesma razão: coerência com a
   LGPD. WOFF2 variáveis, subset latino, nome com o hash do conteúdo — por
   isso o cache é `immutable` (_headers): arquivo novo, nome novo. */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/cormorant-garamond-latin-wght-normal.d80df8ff5a.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url('/fonts/cormorant-garamond-latin-wght-italic.6f2f5c3b1a.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin-wght-normal.18be452724.woff2') format('woff2');
}

/* Cores de estado medidas contra o fundo (WCAG 2.x). As anteriores não
   passavam: no escuro, `--down` #8c3a3a dava 2,6:1 (abaixo até dos 3:1 de
   elemento gráfico), `--degraded` 3,9:1 e o `--muted` do texto secundário
   3,3:1; no claro, `--muted` 2,8:1. Todas as de texto abaixo passam de
   4,5:1 sobre `--bg` e `--panel` nos dois temas. `*-fundo` é só preenchimento
   atrás de texto em `--text`. */
:root {
  --bg: #0d0c0a;
  --panel: #161412;
  --panel-2: #1d1a17;
  --border: #2a2622;
  --text: #e6e1d6;
  --muted: #948a7c;
  --accent: #c08030;
  --accent-forte: #d08e3c;
  --up: #5fb878;
  --degraded: #d4a03c;
  --down: #e06666;
  --nd: #3a3530;
  --up-fundo: #16261b;
  --degraded-fundo: #2b2211;
  --down-fundo: #2e1515;
  --foco: #e0a050;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4efe6;
  --panel: #ede8df;
  --panel-2: #e6e0d5;
  --border: #d3cbbd;
  --text: #1c1a17;
  --muted: #6b6152;
  --accent: #8f5a14;
  --accent-forte: #7a4c10;
  --up: #23703d;
  --degraded: #8a5a0a;
  --down: #a8282a;
  --nd: #cdc5b7;
  --up-fundo: #dcebdf;
  --degraded-fundo: #f1e3c4;
  --down-fundo: #f8e4e2;
  --foco: #7a4c10;
  color-scheme: light;
}

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

/* Com a CSP sem 'unsafe-inline', o HTML não carrega atributo de estilo:
   mostrar e esconder é o atributo `hidden`, que precisa ganhar de `display`. */
[hidden] { display: none !important; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); }
a:hover { color: var(--accent-forte); }

/* Foco sempre visível no teclado; o mouse não ganha o anel. */
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; border-radius: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.pular {
  position: absolute; left: 12px; top: -48px; z-index: 20;
  background: var(--accent); color: var(--bg); padding: 8px 12px; border-radius: 3px;
  text-decoration: none; font-size: 12px;
}
.pular:focus { top: 12px; }

/* ── Topo ─────────────────────────────────────────────────────────────── */
.topo { border-bottom: 1px solid var(--border); background: var(--bg); }
.topo-in {
  max-width: 1120px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.marca {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'Cormorant Garamond', Georgia, serif; font-size: 22px; font-weight: 500;
  color: var(--text); text-decoration: none; line-height: 1;
}
.marca em { font-style: italic; color: var(--accent); font-weight: 400; }
.marca:hover { color: var(--text); }
.marca-ponto { width: 10px; height: 10px; border-radius: 50%; background: var(--up); flex: none; }
.topo-acoes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  border-radius: 3px; padding: 7px 12px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.btn-primario:hover { background: var(--accent-forte); border-color: var(--accent-forte); color: var(--bg); }
.btn-fantasma { color: var(--muted); }
.btn-pequeno { padding: 4px 10px; min-height: 28px; font-size: 10px; }

.inscricao { border-top: 1px solid var(--border); background: var(--panel); }
.inscricao-in { max-width: 1120px; margin: 0 auto; padding: 14px 16px; display: grid; gap: 10px; }
.inscricao-texto { font-size: 12px; color: var(--muted); }
.inscricao-form { display: flex; gap: 6px; flex-wrap: wrap; }
.campo {
  flex: 1 1 200px; min-width: 0; font: inherit; font-size: 13px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 7px 10px; min-height: 32px;
}
.campo:focus-visible { border-color: var(--foco); }
.inscricao-ok { font-size: 12px; color: var(--up); }
.inscricao-erro { font-size: 12px; color: var(--down); }
.inscricao-consent { font-size: 11px; }
.inscricao-turnstile { flex-basis: 100%; min-height: 65px; }

/* ── Conteúdo ─────────────────────────────────────────────────────────── */
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }

.faixa {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 20px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel);
}
.faixa-icone {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: var(--nd); color: var(--text);
}
.faixa-titulo {
  font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500;
  font-size: clamp(22px, 5vw, 30px); line-height: 1.15;
}
.faixa-detalhe { font-size: 12px; color: var(--muted); margin-top: 4px; }
.faixa-detalhe:empty { display: none; }
.faixa.estado-up { background: var(--up-fundo); border-color: var(--up); }
.faixa.estado-up .faixa-icone { background: var(--up); color: var(--bg); }
.faixa.estado-degraded { background: var(--degraded-fundo); border-color: var(--degraded); }
.faixa.estado-degraded .faixa-icone { background: var(--degraded); color: var(--bg); }
.faixa.estado-down { background: var(--down-fundo); border-color: var(--down); }
.faixa.estado-down .faixa-icone { background: var(--down); color: var(--bg); }
.faixa.estado-unknown { border-style: dashed; }
.faixa.estado-checking .faixa-icone { animation: pulso 1.2s ease-in-out infinite; }

.idade-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.idade { font-size: 11px; color: var(--muted); }
.idade .stale { color: var(--degraded); }

.secao { margin-top: 36px; }
.secao:focus { outline: none; }
.secao-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.secao h2 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 24px; line-height: 1.1; }
.secao-nota { font-size: 11px; color: var(--muted); }

.grupo + .grupo { margin-top: 16px; }
.grupo-titulo { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px 2px; font-weight: 500; }
.componentes { list-style: none; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.componente { padding: 14px 16px 12px; }
.componente + .componente { border-top: 1px solid var(--border); }

.comp-linha { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.comp-nome { min-width: 0; }
.comp-nome a, .comp-nome-txt {
  font-family: 'Cormorant Garamond', Georgia, serif; font-size: 18px; font-weight: 600;
  color: var(--text); text-decoration: none;
}
.comp-nome a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.comp-url { display: block; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado { font-size: 11px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--muted); }
.estado-ic {
  width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 800; background: var(--nd); color: var(--text);
}
.estado.up { color: var(--up); }
.estado.up .estado-ic { background: var(--up); color: var(--bg); }
.estado.degraded { color: var(--degraded); }
.estado.degraded .estado-ic { background: var(--degraded); color: var(--bg); }
.estado.down { color: var(--down); }
.estado.down .estado-ic { background: var(--down); color: var(--bg); }
.estado.checking .estado-ic { animation: pulso 1.2s ease-in-out infinite; }
.estado.unknown .estado-ic { background: var(--nd); color: var(--text); }

.comp-nota { font-size: 11px; color: var(--muted); margin-top: 4px; }
.comp-nota:empty { display: none; }
.comp-nota .down { color: var(--down); }
.comp-nota .degraded { color: var(--degraded); }
.selo {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px;
  border: 1px solid var(--border); color: var(--muted); margin-left: 4px;
}

/* Barras de histórico: uma por período (dia, com o D1; hora, sem ele). */
.barras { display: flex; gap: 2px; height: 30px; margin-top: 10px; align-items: stretch; }
.b { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--nd); cursor: pointer; }
.b.up { background: var(--up); }
.b.degraded { background: var(--degraded); }
.b.down { background: var(--down); }
.b:hover, .b.ativa { opacity: 0.7; outline: 1px solid var(--text); outline-offset: 1px; }
.barras-rodape { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; color: var(--muted); margin-top: 5px; }
.barras-rodape .uptime { color: var(--text); flex: 1; text-align: center; }
.barra-info { font-size: 11px; color: var(--text); margin-top: 4px; min-height: 1.5em; }
.so-estreito { display: none; }

.comp-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; font-size: 10px; color: var(--muted); }
.checks-toggle {
  font: inherit; font-size: 10px; background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px 0; letter-spacing: 0.04em; margin-left: auto; min-height: 24px;
}
.checks-toggle:hover { color: var(--accent); }
.checks-toggle.has-problems { color: var(--down); font-weight: 600; }
.checks { display: none; list-style: none; margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.checks.show { display: grid; gap: 4px; }
.check { display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: 8px; font-size: 11px; line-height: 1.45; }
.check-ic { font-size: 10px; font-weight: 800; color: var(--muted); padding-top: 1px; }
.check.up .check-ic { color: var(--up); }
.check.degraded .check-ic { color: var(--degraded); }
.check.down .check-ic { color: var(--down); }
.check-label { color: var(--muted); }
.check-detail { grid-column: 2; color: var(--text); overflow-wrap: anywhere; }
.check.up .check-detail { color: var(--muted); }
.check.degraded .check-detail { color: var(--degraded); }
.check.down .check-detail { color: var(--down); }
.check-quando { color: var(--muted); }

.legenda { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 10px; color: var(--muted); }
.legenda li { display: inline-flex; align-items: center; gap: 6px; }
.b-amostra { width: 8px; height: 14px; border-radius: 2px; background: var(--nd); display: inline-block; }
.b-amostra.up { background: var(--up); }
.b-amostra.degraded { background: var(--degraded); }
.b-amostra.down { background: var(--down); }

/* Incidentes em linha do tempo, por dia. */
.incidentes { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); padding: 6px 16px; }
.dia + .dia { border-top: 1px solid var(--border); }
.dia-titulo { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 10px 0 4px; font-weight: 500; }
.dia-lista { list-style: none; padding-bottom: 8px; }
.inc { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 8px; padding: 6px 0; font-size: 12px; }
.inc-ic { font-weight: 800; font-size: 11px; padding-top: 1px; }
.inc.down .inc-ic { color: var(--down); }
.inc.degraded .inc-ic { color: var(--degraded); }
.inc-titulo strong { font-weight: 600; }
.inc-quando, .inc-causa { color: var(--muted); font-size: 11px; }
.inc-aberto { color: var(--down); font-weight: 600; }
.inc.degraded .inc-aberto { color: var(--degraded); }
.vazio { font-size: 12px; color: var(--muted); padding: 10px 0; }
.aviso { color: var(--degraded); }

/* Painéis simples (latência, cotas). */
.painel { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); padding: 12px 16px; display: grid; gap: 4px; }
.panel-empty { font-size: 11px; color: var(--muted); }
.panel-empty.aviso { color: var(--degraded); }
.panel-empty.mt { margin-top: 6px; }

.lat { display: flex; align-items: center; gap: 10px; font-size: 11px; line-height: 1.8; }
.lat-name { flex: 0 0 34%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lat-spark { flex: 0 0 auto; display: block; }
.lat-spark path { fill: none; stroke: var(--muted); stroke-width: 1.3; }
.lat-spark path.degraded { stroke: var(--degraded); }
.lat-spark path.down { stroke: var(--down); }
.lat-spark line.deploy { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; }
.lat-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.lat-trend { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.lat-trend.piorando { color: var(--degraded); font-weight: 600; }
.lat-trend.melhorando { color: var(--up); }

.terceiros { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.tp {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel); padding: 10px 12px;
  text-decoration: none; color: var(--text);
}
.tp:hover { border-color: var(--accent); color: var(--text); }
.tp-info { flex: 1 1 auto; min-width: 0; }
.tp-nome { font-weight: 600; font-size: 12px; }
.tp-desc { display: block; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quota { display: flex; align-items: center; gap: 10px; font-size: 11px; line-height: 1.7; }
.quota-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.quota-bar { flex: 1 1 auto; min-width: 30px; height: 4px; border-radius: 2px; background: var(--nd); overflow: hidden; }
.quota-fill { display: block; height: 100%; width: 0; background: var(--up); border-radius: 2px; transition: width 0.7s ease; }
.quota-fill.degraded { background: var(--degraded); }
.quota-fill.down { background: var(--down); }
.quota-fill.unknown { background: var(--muted); }
.quota-val { flex: 0 0 auto; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.quota-val.degraded { color: var(--degraded); }
.quota-val.down { color: var(--down); }

/* Detalhe por Worker (painel de cotas). */
.tabela { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 10px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.tabela col.c-script { width: 34%; }
.tabela caption { text-align: left; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-bottom: 4px; }
.tabela th, .tabela td { text-align: right; padding: 3px 0 3px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
.tabela th:first-child { text-align: left; padding-left: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.tabela thead th { color: var(--muted); font-weight: 400; border-top: none; }
.tabela td.degraded { color: var(--degraded); }
.tabela td.down { color: var(--down); }
.por-hora { margin-top: 12px; }
.por-hora-titulo { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.barras.curtas { height: 18px; margin-top: 6px; }
.barras.curtas .b { cursor: default; }

.rodape { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); text-align: center; }
.rodape a { text-decoration: none; }
.rodape a:hover { text-decoration: underline; }
.rodape-nota { margin-top: 6px; }

/* ── Medidor de uptime ────────────────────────────────────────────────── */
.topo-grade { display: grid; gap: 16px; }
.medidor { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); padding: 16px 20px; }
.medidor-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.medidor h2 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; font-size: 22px; line-height: 1.1; }
.medidor-corpo { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.anel { position: relative; width: 112px; height: 112px; flex: none; }
.anel svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.anel circle { fill: none; stroke-width: 9; }
.anel-fundo { stroke: var(--nd); }
.anel-valor { stroke: var(--muted); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray 0.8s ease; }
.anel.up .anel-valor { stroke: var(--up); }
.anel.degraded .anel-valor { stroke: var(--degraded); }
.anel.down .anel-valor { stroke: var(--down); }
.anel-texto { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.anel-texto strong { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.anel-texto span { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.janelas { list-style: none; flex: 1 1 180px; min-width: 0; display: grid; gap: 12px; }
.janela { display: grid; grid-template-columns: 44px 1fr; column-gap: 10px; row-gap: 4px; align-items: baseline; }
.janela-rot { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.janela-pct { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.janela-barra { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--nd); overflow: hidden; }
.janela-barra i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--muted); transition: width 0.7s ease; }
.janela.up .janela-barra i { background: var(--up); }
.janela.degraded .janela-barra i { background: var(--degraded); }
.janela.down .janela-barra i { background: var(--down); }

.blocos { display: grid; gap: 0; }

/* Computador: blocos lado a lado em vez de uma coluna única comprida. */
@media (min-width: 960px) {
  .wrap { padding-top: 28px; }
  .topo-grade { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: stretch; }
  .topo-grade .resumo { display: flex; flex-direction: column; justify-content: space-between; }
  .topo-grade .faixa { flex: 1; align-items: center; padding: 24px; }
  .medidor { padding: 18px 22px; }
  .componentes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 0; background: none; border-radius: 0; }
  .componente { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
  .componente + .componente { border-top: 1px solid var(--border); }
  .blocos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
  .blocos .secao { min-width: 0; }
  .terceiros { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@keyframes pulso { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* Celular: 30 barras em vez de 90 (e 24 em vez de 48), que é o que cabe
   legível em 360 px — o padrão das páginas de status. As barras escondidas
   continuam no DOM; o resumo acessível fala da janela inteira. */
@media (max-width: 600px) {
  .barras.diario .b:nth-child(-n+60) { display: none; }
  .barras.horario .b:nth-child(-n+24) { display: none; }
  .so-largo { display: none; }
  .so-estreito { display: inline; }
  .quota { flex-wrap: wrap; gap: 2px 10px; padding-bottom: 6px; }
  .quota-bar { flex-basis: 100%; order: 3; }
  .lat { flex-wrap: wrap; gap: 2px 8px; }
  .lat-name { flex-basis: 100%; }
  .lat-val { margin-left: 0; }
  .faixa { padding: 14px; }
  .tabela { font-size: 10px; }
  .tabela th, .tabela td { padding-left: 6px; }
  .tabela td { white-space: normal; }
  .marca { font-size: 19px; }
}

/* Quem pediu menos movimento não recebe pulso nem transição. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
