Explorar o código

fix(auth): eximir GET /api/agents/{slug}/binary del middleware de sesión (auth Bearer propia)

gnacho hai 4 meses
pai
achega
1972b40935
Modificáronse 5 ficheiros con 229 adicións e 107 borrados
  1. 5 4
      server-go/internal/auth/middleware.go
  2. 141 80
      web/app.js
  3. 1 0
      web/i18n.js
  4. 46 18
      web/index.html
  5. 36 5
      web/styles.css

+ 5 - 4
server-go/internal/auth/middleware.go

@@ -44,14 +44,15 @@ func WriteError(w http.ResponseWriter, status int, code string, message ...strin
 }
 
 // RequireAuth es middleware global: todo /api/* exige sesión salvo
-// /api/health, /api/auth/login y /api/ingest/agent (este último lleva auth
-// propia Bearer por token de equipo, SPEC-AGENTE-PILOTO §1 — la sesión es de
-// humanos). Fallo → 401 {error:'unauthorized'}.
+// /api/health, /api/auth/login, /api/ingest/agent (auth Bearer por token
+// de equipo) y /api/agents/{slug}/binary (auth Bearer por token de agente,
+// Fase 6.2). Fallo → 401 {error:'unauthorized'}.
 func RequireAuth(d *db.DB, secret string, next http.Handler) http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 		path := r.URL.Path
 		if !strings.HasPrefix(path, "/api/") || path == "/api/health" || path == "/api/auth/login" ||
-			path == "/api/ingest/agent" {
+			path == "/api/ingest/agent" ||
+			(strings.HasPrefix(path, "/api/agents/") && strings.HasSuffix(path, "/binary")) {
 			next.ServeHTTP(w, r)
 			return
 		}

+ 141 - 80
web/app.js

@@ -257,7 +257,7 @@ function renderTicker() {
   el.innerHTML = items.join('') + items.join('')
 }
 
-/* ---------- stage 0: health ring ---------- */
+/* ---------- stage 0: health ring + advertencias + ancho de banda ---------- */
 let ringPlayed = false
 function playRing() {
   if (ringPlayed) return
@@ -266,6 +266,9 @@ function playRing() {
   const num = document.getElementById('ringNum')
   const C = 590.6
   const score = DEMO.score
+  animateNumber(document.getElementById('hDown'), DEMO_WAN.downMbps, { decimals: 1, duration: 1400 })
+  animateNumber(document.getElementById('hUp'), DEMO_WAN.upMbps, { decimals: 1, duration: 1400 })
+  animateNumber(document.getElementById('hLat'), DEMO_WAN.latencyMs, { duration: 1400 })
   if (reduceMotion) { arc.style.strokeDashoffset = C * (1 - score / 100); num.textContent = score; return }
   const dur = 1300
   const start = performance.now()
@@ -280,79 +283,114 @@ function playRing() {
   requestAnimationFrame(frame)
 }
 
-/* ---------- stage 1: traffic chart ---------- */
+/* ---------- stage 1: tráfico WAN por rango (1h/24h/7d/30d) ---------- */
 let trafficPlayed = false
 let trafficTimer = null
-function genSeries(n, base, amp, seed = 1) {
-  const out = []; let s = seed
-  for (let i = 0; i < n; i++) {
-    s = (s * 9301 + 49297) % 233280
-    const noise = s / 233280
-    out.push(Math.max(2, base + Math.sin(i / 4) * amp * 0.6 + noise * amp))
-  }
-  return out
-}
-function pathFrom(data, W, H, max) {
-  const step = W / (data.length - 1)
-  return data.map((v, i) => `${i === 0 ? 'M' : 'L'}${(i * step).toFixed(1)} ${(H - (v / max) * (H - 10) - 5).toFixed(1)}`).join(' ')
-}
-function playTraffic() {
-  if (trafficPlayed) return
-  trafficPlayed = true
-  const W = 480, H = 160
-  const downData = genSeries(52, DEMO.down, 22, 7)
-  const upData = genSeries(52, DEMO.up, 6, 13)
-  const max = 120
+let trafficRange = '24h'
+const TRAFFIC_TICKS = { '1h': 5, '24h': 6, '7d': 7, '30d': 5 }
+const NS_T = 'http://www.w3.org/2000/svg'
+
+function renderTrafficChart(animate) {
+  const data = DEMO_TRAFFIC[trafficRange]
+  if (!data || data.length < 2) return
+  const W = 480, H = 200, padL = 8, padR = 8, padT = 14, padB = 26
+  const max = Math.max(1, ...data.map((p) => Math.max(p.down, p.up))) * 1.15
+  const stepX = (W - padL - padR) / (data.length - 1)
+  const X = (i) => padL + i * stepX
+  const Y = (v) => padT + (H - padT - padB) * (1 - v / max)
+  const path = (key) => data.map((p, i) => `${i ? 'L' : 'M'}${X(i).toFixed(1)} ${Y(p[key]).toFixed(1)}`).join(' ')
+  const down = path('down'), up = path('up')
   const lineDown = document.getElementById('lineDown')
   const lineUp = document.getElementById('lineUp')
   const areaDown = document.getElementById('areaDown')
-  const dPath = pathFrom(downData, W, H, max)
-  const uPath = pathFrom(upData, W, H, max)
-  lineDown.setAttribute('d', dPath)
-  lineUp.setAttribute('d', uPath)
-  areaDown.setAttribute('d', dPath + ` L${W} ${H} L0 ${H} Z`)
-  if (reduceMotion) {
-    areaDown.setAttribute('opacity', '1')
-    document.getElementById('wanDown').textContent = DEMO.down.toFixed(1)
-    document.getElementById('wanUp').textContent = DEMO.up.toFixed(1)
-    document.getElementById('wanLat').textContent = DEMO.latency
-    return
+  const areaUp = document.getElementById('areaUp')
+  const x0 = X(0).toFixed(1), xN = X(data.length - 1).toFixed(1)
+  lineDown.setAttribute('d', down)
+  lineUp.setAttribute('d', up)
+  areaDown.setAttribute('d', `${down} L${xN} ${H} L${x0} ${H} Z`)
+  areaUp.setAttribute('d', `${up} L${xN} ${H} L${x0} ${H} Z`)
+  // rejilla horizontal
+  const grid = document.getElementById('trafficGrid')
+  grid.innerHTML = ''
+  for (let g = 1; g <= 3; g++) {
+    const gy = padT + (H - padT - padB) * (g / 4)
+    const el = document.createElementNS(NS_T, 'line')
+    el.setAttribute('x1', padL); el.setAttribute('x2', W - padR); el.setAttribute('y1', gy); el.setAttribute('y2', gy)
+    el.setAttribute('stroke', 'rgb(var(--border))'); el.setAttribute('stroke-dasharray', '3 6'); el.setAttribute('opacity', '0.5')
+    grid.appendChild(el)
   }
-  const Ld = lineDown.getTotalLength()
-  const Lu = lineUp.getTotalLength()
-  lineDown.style.strokeDasharray = Ld
-  lineUp.style.strokeDasharray = Lu
-  lineDown.style.strokeDashoffset = Ld
-  lineUp.style.strokeDashoffset = Lu
-  const start = performance.now()
-  const dur = 1500
-  function frame(now) {
-    const p = Math.min(1, (now - start) / dur)
-    const e = easeOutCubic(p)
-    lineDown.style.strokeDashoffset = Ld * (1 - e)
-    lineUp.style.strokeDashoffset = Lu * (1 - e)
-    areaDown.setAttribute('opacity', String(e * 0.9))
-    if (p < 1) requestAnimationFrame(frame)
-    else startLiveJitter()
+  // ticks del eje X
+  const ticks = document.getElementById('trafficXTicks')
+  ticks.innerHTML = ''
+  const n = TRAFFIC_TICKS[trafficRange] || 5
+  for (let k = 0; k < n; k++) {
+    const idx = Math.round((k * (data.length - 1)) / (n - 1))
+    const tx = document.createElementNS(NS_T, 'text')
+    tx.setAttribute('x', X(idx)); tx.setAttribute('y', H - 8); tx.setAttribute('text-anchor', 'middle')
+    tx.textContent = data[idx].t
+    ticks.appendChild(tx)
+  }
+  if (animate) {
+    const Ld = lineDown.getTotalLength()
+    const Lu = lineUp.getTotalLength()
+    lineDown.style.strokeDasharray = Ld; lineDown.style.strokeDashoffset = Ld
+    lineUp.style.strokeDasharray = Lu; lineUp.style.strokeDashoffset = Lu
+    const start = performance.now(), dur = 1400
+    function frame(now) {
+      const p = Math.min(1, (now - start) / dur)
+      const e = easeOutCubic(p)
+      lineDown.style.strokeDashoffset = Ld * (1 - e)
+      lineUp.style.strokeDashoffset = Lu * (1 - e)
+      areaDown.setAttribute('opacity', String(e * 0.9))
+      areaUp.setAttribute('opacity', String(e * 0.8))
+      if (p < 1) requestAnimationFrame(frame)
+    }
+    requestAnimationFrame(frame)
+  } else {
+    lineDown.style.strokeDasharray = ''
+    lineDown.style.strokeDashoffset = ''
+    lineUp.style.strokeDasharray = ''
+    lineUp.style.strokeDashoffset = ''
+    areaDown.setAttribute('opacity', '0.9')
+    areaUp.setAttribute('opacity', '0.8')
   }
-  requestAnimationFrame(frame)
-  animateNumber(document.getElementById('wanDown'), DEMO.down, { decimals: 1, duration: 1400 })
-  animateNumber(document.getElementById('wanUp'), DEMO.up, { decimals: 1, duration: 1400 })
-  animateNumber(document.getElementById('wanLat'), DEMO.latency, { duration: 1400 })
 }
-function startLiveJitter() {
-  if (trafficTimer) return
-  const downEl = document.getElementById('wanDown')
-  const upEl = document.getElementById('wanUp')
+
+function renderWanFooter() {
+  const w = DEMO_WAN
+  const set = (id, v) => { const el = document.getElementById(id); if (el) el.textContent = v }
+  set('wanPeak', `${w.peakTodayMbps} Mbps ↓`)
+  set('wanAvg', `${w.avgDownMbps} Mbps ↓`)
+  set('wanTotal', w.total24h)
+  set('wanLoss', `${w.lossPct} %`)
+}
+
+function playTraffic() {
+  if (trafficPlayed) return
+  trafficPlayed = true
+  renderTrafficChart(true)
+  renderWanFooter()
+  animateNumber(document.getElementById('wanDown'), DEMO_WAN.downMbps, { decimals: 1, duration: 1400 })
+  animateNumber(document.getElementById('wanUp'), DEMO_WAN.upMbps, { decimals: 1, duration: 1400 })
+  animateNumber(document.getElementById('wanLat'), DEMO_WAN.latencyMs, { duration: 1400 })
+  if (reduceMotion) return
   trafficTimer = setInterval(() => {
+    const downEl = document.getElementById('wanDown')
     if (!downEl.isConnected) return
-    const d = Math.max(55, DEMO.down + (Math.random() - 0.5) * 7)
-    const u = Math.max(9, DEMO.up + (Math.random() - 0.5) * 2.5)
+    const d = Math.max(55, DEMO_WAN.downMbps + (Math.random() - 0.5) * 7)
+    const u = Math.max(9, DEMO_WAN.upMbps + (Math.random() - 0.5) * 2.5)
     downEl.textContent = d.toFixed(1)
-    upEl.textContent = u.toFixed(1)
+    document.getElementById('wanUp').textContent = u.toFixed(1)
   }, 2600)
 }
 
+function setTrafficRange(r) {
+  if (trafficRange === r) return
+  trafficRange = r
+  document.querySelectorAll('#trafficRanges button').forEach((b) => b.classList.toggle('on', b.dataset.range === r))
+  renderTrafficChart(false)
+}
+
 /* ---------- stage 2: topologia fiel a la app (model.ts + TopologyMap.tsx) ---------- */
 let topoBuilt = false
 let routersBuilt = false
@@ -1088,39 +1126,52 @@ function playRouters() {
   fillRouterBars(false)
 }
 
-/* ---------- stage 4: adguard ---------- */
-const AG_DOMAINS = [
-  { d: 'graph.facebook.com', n: 12840 },
-  { d: 'ads.doubleclick.net', n: 9315 },
-  { d: 'app-measurement.com', n: 7602 },
-  { d: 'telemetry.microsoft.com', n: 4188 },
-  { d: 'tracking.miui.com', n: 2941 },
-]
+/* ---------- stage 4: adguard (como la tarjeta de la app) ---------- */
 let agPlayed = false
+const AG_DONUT_C = 248.2
+function renderAdGuardTexts() {
+  const ag = DEMO_ADGUARD
+  const set = (id, v) => { const el = document.getElementById(id); if (el) el.textContent = v }
+  set('agBlockedPct', fmtLocale(ag.blockedPct, 1) + '%')
+  set('agBlockedOf', t('adguard.blockedOf', { blocked: fmtLocale(ag.blocked24h), total: fmtLocale(ag.queries24h) }))
+  set('agTrackers', fmtLocale(ag.trackersBlocked))
+  set('agDns', fmtLocale(ag.dnsLatencyMs) + ' ms')
+}
 function playAdGuard() {
+  renderAdGuardTexts()
+  const ag = DEMO_ADGUARD
+  const arc = document.getElementById('agDonutArc')
   if (agPlayed) return
   agPlayed = true
-  const q = document.getElementById('agQueries')
-  const b = document.getElementById('agBlocked')
-  const c = document.getElementById('agClients')
-  animateNumber(q, 184523, { duration: 1400, format: x => fmtLocale(Math.round(x)) })
-  animateNumber(b, 23, { duration: 1400, format: x => Math.round(x) + '%' })
-  animateNumber(c, DEMO.clients, { duration: 1200, format: x => Math.round(x) + '/' + DEMO.clientsTotal })
+  // animación del arco del donut
+  if (reduceMotion) {
+    arc.style.strokeDashoffset = AG_DONUT_C * (1 - ag.blockedPct / 100)
+  } else {
+    const start = performance.now(), dur = 1100
+    function frame(now) {
+      const p = Math.min(1, (now - start) / dur)
+      const e = easeOutCubic(p)
+      arc.style.strokeDashoffset = AG_DONUT_C * (1 - (ag.blockedPct / 100) * e)
+      if (p < 1) requestAnimationFrame(frame)
+    }
+    requestAnimationFrame(frame)
+  }
+  // barras de dominios bloqueados
   const bars = document.getElementById('agBars')
   if (!bars.childElementCount) {
-    const max = AG_DOMAINS[0].n
-    bars.innerHTML = AG_DOMAINS.map(x => `
+    const max = ag.topBlocked[0].count
+    bars.innerHTML = ag.topBlocked.map((x) => `
       <div class="ag-bar-row">
-        <span class="d">${x.d}</span>
-        <div class="bar"><i data-w="${Math.round((x.n / max) * 100)}"></i></div>
-        <span class="n">${fmtLocale(x.n)}</span>
+        <span class="d">${x.domain}</span>
+        <div class="bar"><i data-w="${Math.round((x.count / max) * 100)}"></i></div>
+        <span class="n">${fmtLocale(x.count)}</span>
       </div>
     `).join('')
   }
   bars.querySelectorAll('.bar i').forEach((bar, i) => {
     const w = bar.dataset.w
     if (reduceMotion) { bar.style.width = w + '%'; return }
-    setTimeout(() => { bar.style.width = w + '%' }, 150 + i * 120)
+    setTimeout(() => { bar.style.width = w + '%' }, 200 + i * 120)
   })
 }
 
@@ -1261,6 +1312,15 @@ function initKofi() {
 }
 
 /* ---------- boot ---------- */
+function initTrafficRanges() {
+  const wrap = document.getElementById('trafficRanges')
+  if (!wrap) return
+  wrap.addEventListener('click', (e) => {
+    const btn = e.target.closest('button[data-range]')
+    if (btn) setTrafficRange(btn.dataset.range)
+  })
+}
+
 document.addEventListener('DOMContentLoaded', () => {
   initAppearance()
   initBackgroundCanvas()
@@ -1270,5 +1330,6 @@ document.addEventListener('DOMContentLoaded', () => {
   initTheater()
   initCopy()
   initKofi()
+  initTrafficRanges()
   heroCountUps()
 })

+ 1 - 0
web/i18n.js

@@ -1064,6 +1064,7 @@ function applyLang(lang) {
   if (typeof renderAlerts === 'function') renderAlerts()
   if (typeof renderRouterNames === 'function') renderRouterNames()
   if (typeof renderTopoNames === 'function') renderTopoNames()
+  if (typeof renderAdGuardTexts === 'function') renderAdGuardTexts()
   if (typeof updateAppearancePanel === 'function') updateAppearancePanel()
 }
 

+ 46 - 18
web/index.html

@@ -215,23 +215,42 @@
               <div class="wan-card card" style="background:rgb(var(--elevated)/0.4);">
                 <div class="wan-head">
                   <span class="label uppercase text-muted" data-i18n="wan.title">Tráfico WAN</span>
+                  <div class="seg seg-ranges" id="trafficRanges" role="tablist" aria-label="Período">
+                    <button type="button" data-range="1h">1h</button>
+                    <button type="button" data-range="24h" class="on">24h</button>
+                    <button type="button" data-range="7d">7d</button>
+                    <button type="button" data-range="30d">30d</button>
+                  </div>
                   <span class="wan-live"><span class="dot"></span><span data-i18n="wan.live">EN VIVO</span></span>
                 </div>
-                <svg id="trafficChart" viewBox="0 0 400 120" preserveAspectRatio="none">
+                <svg id="trafficChart" viewBox="0 0 480 200">
                   <defs>
                     <linearGradient id="fillDown" x1="0" y1="0" x2="0" y2="1">
                       <stop offset="0" stop-color="rgb(var(--accent))" stop-opacity="0.25"/>
                       <stop offset="1" stop-color="rgb(var(--accent))" stop-opacity="0"/>
                     </linearGradient>
+                    <linearGradient id="fillUp" x1="0" y1="0" x2="0" y2="1">
+                      <stop offset="0" stop-color="rgb(var(--tunnel))" stop-opacity="0.2"/>
+                      <stop offset="1" stop-color="rgb(var(--tunnel))" stop-opacity="0"/>
+                    </linearGradient>
                   </defs>
+                  <g id="trafficGrid"></g>
                   <path id="areaDown" fill="url(#fillDown)" opacity="0"/>
+                  <path id="areaUp" fill="url(#fillUp)" opacity="0"/>
                   <path id="lineDown" fill="none" stroke="rgb(var(--accent))" stroke-width="2" stroke-linecap="round"/>
                   <path id="lineUp" fill="none" stroke="rgb(var(--tunnel))" stroke-width="2" stroke-linecap="round"/>
+                  <g id="trafficXTicks" class="traffic-ticks"></g>
                 </svg>
-                <div style="display:flex;gap:1.5rem;margin-top:0.6rem;flex-wrap:wrap;">
+                <div class="wan-stats">
                   <span class="caption font-mono"><span class="text-accent">↓ <span id="wanDown">0.0</span> Mbps</span></span>
                   <span class="caption font-mono"><span class="text-tunnel">↑ <span id="wanUp">0.0</span> Mbps</span></span>
-                  <span class="caption font-mono text-muted"><span data-i18n="strip.latency">Latencia</span> <span id="wanLat">0</span> ms · 24h: 1,32 TB</span>
+                  <span class="caption font-mono text-muted"><span data-i18n="strip.latency">Latencia</span> <span id="wanLat">0</span> ms</span>
+                </div>
+                <div class="wan-footer">
+                  <div><span class="k" data-i18n="wan.peak">Pico hoy</span><span class="v font-mono" id="wanPeak">0 Mbps ↓</span></div>
+                  <div><span class="k" data-i18n="wan.avg">Media</span><span class="v font-mono" id="wanAvg">0 Mbps ↓</span></div>
+                  <div><span class="k" data-i18n="wan.total">Total 24 h</span><span class="v font-mono" id="wanTotal">—</span></div>
+                  <div><span class="k" data-i18n="wan.loss">Pérdida</span><span class="v font-mono" id="wanLoss">0 %</span></div>
                 </div>
               </div>
             </div>
@@ -248,25 +267,34 @@
 
             <!-- Stage 4: AdGuard -->
             <div class="stage" id="stage4">
-              <div class="ag-grid">
-                <div style="display:flex;flex-direction:column;gap:0.9rem;">
-                  <div class="ag-stat card" style="background:rgb(var(--elevated)/0.4);">
-                    <div class="v font-mono text-accent" id="agQueries">0</div>
-                    <div class="k" data-i18n="adguard.queries">consultas · 24 h</div>
-                  </div>
-                  <div class="ag-stat card" style="background:rgb(var(--elevated)/0.4);">
-                    <div class="v font-mono text-danger" id="agBlocked">0%</div>
-                    <div class="k" data-i18n="adguard.blocked">bloqueado</div>
-                  </div>
-                  <div class="ag-stat card" style="background:rgb(var(--elevated)/0.4);">
-                    <div class="v font-mono text-ok" id="agClients">0/65</div>
-                    <div class="k" data-i18n="adguard.clients">clientes lo usan</div>
+              <div class="ag-card card" style="background:rgb(var(--elevated)/0.4);">
+                <div class="ag-head">
+                  <span class="label uppercase text-muted"><svg viewBox="0 0 24 24" fill="none" stroke="rgb(var(--ok))" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg><span data-i18n="adguard.title">AdGuard Home</span></span>
+                  <span class="pill ok"><span class="pill-dot"></span><span data-i18n="adguard.active">Activo</span></span>
+                </div>
+                <div class="ag-main">
+                  <div>
+                    <div class="ag-pct font-mono text-ok" id="agBlockedPct">0%</div>
+                    <div class="ag-of font-mono" id="agBlockedOf">0</div>
                   </div>
+                  <svg id="agDonut" width="88" height="88" viewBox="0 0 88 88" class="ag-donut" role="img">
+                    <circle cx="44" cy="44" r="39.5" fill="none" stroke="rgb(var(--border))" stroke-width="9"/>
+                    <circle id="agDonutArc" cx="44" cy="44" r="39.5" fill="none" stroke="rgb(var(--ok))" stroke-width="9" stroke-linecap="round"
+                      stroke-dasharray="248.2" stroke-dashoffset="248.2" transform="rotate(-90 44 44)"/>
+                  </svg>
+                </div>
+                <div class="ag-grid2">
+                  <div class="ag-cell"><span class="k" data-i18n="adguard.trackers">Rastreadores</span><span class="v font-mono" id="agTrackers">0</span></div>
+                  <div class="ag-cell"><span class="k" data-i18n="adguard.dns">DNS medio</span><span class="v font-mono" id="agDns">0 ms</span></div>
                 </div>
-                <div class="card" style="background:rgb(var(--elevated)/0.4);padding:1rem 1.1rem;">
-                  <div class="label uppercase text-muted" style="margin-bottom:0.75rem;" data-i18n="adguard.domains">Dominios más bloqueados</div>
+                <div class="ag-domains">
+                  <span class="label uppercase text-muted" data-i18n="adguard.domains">Dominios más bloqueados</span>
                   <div id="agBars"></div>
                 </div>
+                <a class="ag-open" id="agOpen" href="http://192.168.8.1:3000" target="_blank" rel="noreferrer">
+                  <span data-i18n="adguard.open">Abrir panel</span>
+                  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M7 17 17 7"/><path d="M7 7h10v10"/></svg>
+                </a>
               </div>
             </div>
 

+ 36 - 5
web/styles.css

@@ -254,9 +254,24 @@ section.block { padding: 5rem 0; }
 .wan-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.75rem; }
 .wan-live { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: rgb(var(--ok)); font-weight: 700; letter-spacing: 0.08em; }
 .wan-live .dot { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--ok)); animation: pulseDot 1.6s infinite; }
-#trafficChart { width: 100%; height: 150px; display: block; }
+#trafficChart { width: 100%; height: auto; display: block; }
 .wan-stats { display: flex; gap: 2.25rem; margin-top: 1rem; flex-wrap: wrap; }
 .wan-stats span { font-size: 1.05rem; }
+.wan-footer { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-top: 1rem; border-top: 1px solid rgb(var(--border)); padding-top: 0.85rem; }
+.wan-footer .k { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: rgb(var(--text-muted)); font-weight: 600; }
+.wan-footer .v { display: block; margin-top: 0.2rem; font-size: 0.85rem; font-weight: 600; color: rgb(var(--text-primary)); }
+@media (max-width: 560px) { .wan-footer { grid-template-columns: 1fr 1fr; } }
+.traffic-ticks text { fill: rgb(var(--text-muted)); font-family: "JetBrains Mono", monospace; font-size: 10px; }
+
+/* salud */
+.health-box { display: flex; flex-direction: column; gap: 0.85rem; align-items: flex-start; max-width: 19rem; }
+.health-note { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; color: rgb(var(--warn)); background: rgb(var(--warn) / 0.1); border: 1px solid rgb(var(--warn) / 0.25); padding: 0.5rem 0.7rem; border-radius: 0.7rem; line-height: 1.4; }
+.health-note svg { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.1rem; }
+.health-stats { display: flex; gap: 1.25rem; flex-wrap: wrap; }
+.health-stats span { font-size: 0.98rem; }
+
+/* segmented control de rangos (4 columnas) */
+.seg-ranges { grid-template-columns: repeat(4, 1fr); }
 
 /* topología svg */
 #topoSvg { width: 100%; height: 100%; display: block; }
@@ -313,12 +328,28 @@ section.block { padding: 5rem 0; }
 .ag-stat { padding: 1rem; }
 .ag-stat .v { font-family: "Space Grotesk", sans-serif; font-size: 2.4rem; font-weight: 700; }
 .ag-stat .k { font-size: 0.85rem; color: rgb(var(--text-muted)); margin-top: 0.2rem; font-weight: 600; }
+.ag-card { width: 100%; max-width: 30rem; padding: 1.1rem 1.2rem; }
+.ag-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; }
+.ag-head .label { display: inline-flex; align-items: center; gap: 0.45rem; }
+.ag-head .label svg { width: 1.1rem; height: 1.1rem; }
+.ag-main { display: flex; align-items: center; gap: 1.4rem; }
+.ag-pct { font-size: 2.6rem; font-weight: 700; line-height: 1; }
+.ag-of { margin-top: 0.4rem; font-size: 0.8rem; color: rgb(var(--text-muted)); }
+.ag-donut { flex-shrink: 0; }
+.ag-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1rem; }
+.ag-cell { background: rgb(var(--elevated)); border-radius: 0.7rem; padding: 0.6rem 0.8rem; }
+.ag-cell .k { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: rgb(var(--text-muted)); font-weight: 600; }
+.ag-cell .v { display: block; margin-top: 0.2rem; font-size: 0.95rem; font-weight: 600; color: rgb(var(--text-primary)); }
+.ag-domains { margin-top: 1rem; }
+.ag-domains > .label { display: block; margin-bottom: 0.55rem; }
+.ag-open { display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 1rem; font-size: 0.85rem; font-weight: 600; color: rgb(var(--text-secondary)); transition: color 150ms ease; }
+.ag-open svg { width: 0.95rem; height: 0.95rem; }
+.ag-open:hover { color: rgb(var(--accent)); }
 .ag-bar-row { display: flex; align-items: center; gap: 0.75rem; margin: 0.55rem 0; font-size: 0.8125rem; }
-.ag-bar-row .d { width: 9rem; text-align: right; color: rgb(var(--text-secondary)); font-family: "JetBrains Mono", monospace; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-html[dir="rtl"] .ag-bar-row .d { text-align: left; }
+.ag-bar-row .d { width: 9rem; text-align: left; color: rgb(var(--text-secondary)); font-family: "JetBrains Mono", monospace; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
 .ag-bar-row .bar { flex: 1; height: 7px; border-radius: 999px; background: rgb(var(--elevated)); overflow: hidden; }
-.ag-bar-row .bar i { display: block; height: 100%; width: 0; background: rgb(var(--danger) / 0.8); border-radius: 999px; transition: width 900ms ease; }
-.ag-bar-row .n { width: 3.5rem; color: rgb(var(--text-muted)); font-family: "JetBrains Mono", monospace; font-size: 0.75rem; }
+.ag-bar-row .bar i { display: block; height: 100%; width: 0; background: rgb(var(--ok) / 0.8); border-radius: 999px; transition: width 900ms ease; }
+.ag-bar-row .n { width: 3.5rem; color: rgb(var(--text-muted)); font-family: "JetBrains Mono", monospace; font-size: 0.75rem; text-align: right; }
 
 /* alertas */
 .feed { display: flex; flex-direction: column; gap: 0.65rem; width: 100%; max-width: 44rem; }