:root {
  /* Tema claro (neutro); a cor de marca do provedor entra por --cor-primaria (abaixo) */
  --bg: #F8FAFC;         /* fundo da página (slate-50) */
  --bg2: #FFFFFF;        /* cards / superfícies */
  --bg3: #F1F5F9;        /* superfície alternativa (slate-100): metric-card, tracks */
  --border: #E2E8F0;     /* slate-200 */
  --text: #0F172A;       /* slate-900 */
  --text2: #64748B;      /* slate-500 */

  /* Semânticos (independentes do accent de marca) */
  --green: #16A34A;   --green-bg: #DCFCE7;
  --yellow: #D97706;  --yellow-bg: #FEF3C7;
  --red: #DC2626;     --red-bg: #FEF2F2;
  --blue: #2563EB;    --blue-bg: #EFF6FF;

  /* Aliases semânticos (usados pelos cards do app.js) */
  --good: var(--green);   --good-bg: var(--green-bg);
  --warn: var(--yellow);  --warn-bg: var(--yellow-bg);
  --bad:  var(--red);     --bad-bg:  var(--red-bg);

  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 2px 8px rgba(0,0,0,.1), 0 8px 24px rgba(0,0,0,.08);
  /* Tipografia: Outfit (UI) + Barlow Condensed (títulos/valores) + JetBrains Mono (dados), com fallback do sistema */
  --font: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-head: 'Barlow Condensed', 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, monospace;

  /* Overrides injetados pelo backend por tenant */
  --cor-primaria: #2563eb;   /* accent de marca (cor_primaria do provedor) */
  --cor-fundo: #F8FAFC;
  --accent: var(--cor-primaria);
  --accent-text: #fff;   /* cor de texto sobre o accent — recalculada por contraste no app.js */
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* Header */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  padding: 16px 0;
  margin-bottom: 32px;
}
header .container { padding-top: 0; padding-bottom: 0; display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 20px; height: 20px; fill: #fff; }
header h1 { font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; line-height: 1.1; }
header p { font-size: 0.8rem; color: var(--text2); }

/* Disclosure discreto perto do botão de iniciar */
.disclaimer-disclosure {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text2);
}
.disclaimer-disclosure summary {
  cursor: pointer;
  color: var(--text2);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.disclaimer-disclosure summary::-webkit-details-marker { display: none; }
.disclaimer-disclosure summary:hover { opacity: 1; }
.disclaimer-disclosure[open] summary { opacity: 1; margin-bottom: 6px; }
.disclaimer-disclosure p,
.disclaimer-disclosure > :not(summary) {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: var(--radius);
  line-height: 1.55;
  box-shadow: var(--shadow);
}

/* Rodapé — texto técnico discreto */
.footer-disclaimer {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text2);
  line-height: 1.5;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

/* Form de entrada */
.setup-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 540px) { .setup-form { grid-template-columns: 1fr; } }

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 600;
}
.form-group input {
  width: 100%;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.form-group input::placeholder { color: var(--text2); }

/* Botão principal */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 13px 28px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  box-shadow: var(--shadow);
  transition: filter 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); box-shadow: var(--shadow-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover { background: var(--bg3); border-color: var(--text2); }

/* Progress global */
#progress-bar-wrap {
  display: none;
  margin-bottom: 24px;
}
.progress-label {
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 6px;
}
.progress-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Seções de resultado */
.section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);   /* faixa de accent da marca no topo do card */
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.section-icon {
  width: 30px; height: 30px;
  background: var(--bg3);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.section-icon svg { width: 15px; height: 15px; fill: var(--text2); }
.section-title { font-family: var(--font-head); font-size: 1.05rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; flex: 1; }
.section-status {
  font-family: var(--font-head);
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.status-waiting { background: var(--bg3); color: var(--text2); }
.status-running { background: var(--blue-bg); color: var(--blue); }
.status-done { background: var(--good-bg); color: var(--good); }
.status-error { background: var(--bad-bg); color: var(--bad); }

.section-body {
  padding: 16px;
}

/* Métricas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.metric-card {
  background: var(--bg3);
  border-radius: 10px;
  padding: 12px;
}
.metric-label { font-family: var(--font-head); font-size: 0.8rem; color: var(--text2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.metric-value { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; line-height: 1; letter-spacing: -.01em; }
.metric-unit { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }

.good { color: var(--good); }
.warn { color: var(--warn); }
.bad  { color: var(--bad); }
.neutral { color: var(--text); }

/* Gráfico de latência */
#latency-chart {
  width: 100%;
  height: 80px;
  display: block;
  margin-top: 12px;
}

/* Barra de velocidade */
.speed-bar-wrap { margin-top: 12px; }
.speed-bar-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text2); margin-bottom: 4px; }
.speed-bar-track { height: 8px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.speed-bar-fill { height: 100%; border-radius: 99px; transition: width 0.2s ease; background: var(--accent); }

/* Tabela de info */
.info-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.info-table tr { border-bottom: 1px solid var(--border); }
.info-table tr:last-child { border-bottom: none; }
.info-table td { padding: 7px 4px; }
.info-table td:first-child { color: var(--text2); width: 48%; }
.info-table td:last-child { color: var(--text); font-weight: 500; word-break: break-all; font-family: var(--font-mono); font-size: 0.8rem; }

/* Badge de status */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-head);
  font-size: 0.82rem; padding: 3px 10px;
  border-radius: 99px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
}
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad  { background: var(--bad-bg); color: var(--bad); }
.badge-neutral { background: var(--bg3); color: var(--text2); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Ações finais */
#actions {
  display: none;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}
#actions .btn-secondary { flex: 1; min-width: 160px; }

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Loading placeholder */
.loading-text { color: var(--text2); font-size: 0.85rem; font-style: italic; }

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric-value { font-size: 1.2rem; }
}

.header-brand { display: flex; align-items: center; gap: 12px; }
#tenant-logo { max-height: 48px; max-width: 140px; object-fit: contain; }

.codigo-relatorio {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 1.05em;
  color: var(--text);
  margin-bottom: 8px;
}
.codigo-relatorio strong { color: var(--accent); font-size: 1.2em; font-family: var(--font-mono); letter-spacing: .02em; }

#banner-fora-rede{
  display:none;
  margin:16px 0 4px;
  padding:14px 18px;
  border-radius: var(--radius);
  border:1px solid var(--red);
  background: var(--red-bg);
  color: var(--red);
  font-size:.9rem;
  line-height:1.5;
  box-shadow: var(--shadow);
}
#banner-fora-rede.visivel{display:block}

/* ── Ring de saúde geral (veredito) ─────────────────────────────── */
.veredicto-flex { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.health-ring { position: relative; width: 104px; height: 104px; flex-shrink: 0; }
.health-ring svg { width: 104px; height: 104px; transform: rotate(-90deg); }
.health-ring .ring-bg { fill: none; stroke: var(--bg3); stroke-width: 9; }
.health-ring .ring-fg { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.health-ring .ring-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--font-head); }
.health-ring .ring-num b { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--text); }
.health-ring .ring-num small { font-size: .58rem; color: var(--text2); text-transform: uppercase; letter-spacing: .1em; margin-top: 3px; }

/* ── Skeleton loaders ───────────────────────────────────────────── */
.skeleton { display: grid; gap: 10px; padding: 4px 0; }
.skel-line { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--bg3) 25%, #eef2f7 37%, var(--bg3) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; }
.skel-line.wide { width: 82%; } .skel-line.mid { width: 56%; } .skel-line.sm { width: 34%; }
.skeleton.idle .skel-line { animation: none; background: var(--bg3); opacity: .5; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── Foco visível (acessibilidade) ──────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── Respeita quem pede menos animação ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .skel-line { animation: none; background: var(--bg3); }
}
