<% var v = snap || {}; var bd = v.breakdown || {};

  var hasRun = v.visibilityScore != null;
  var plats  = v.platforms || [];

  var appc = v.appearedCount, ansc = v.answersCount;

  var quiet = plats.filter(function(p){ return p.visibility==null && p.noOverview > 0; });
  var dead  = plats.filter(function(p){ return p.visibility==null && !(p.noOverview > 0); });
  var _total = (typeof totalRuns !== 'undefined') ? totalRuns : 0;

  var _isStaff = !!(locals.showStaff);
%>
<div class="pg-head" style="margin-bottom:0">
  <div>
    <div class="eyebrow">AI Search / AI Visibility</div>
  </div>
  <div class="ph-right">

    <%- include('../partials/range-picker') %></div>
</div>

<h1 class="claim"><%= title %></h1>
<% if (ansc && appc) { %>
  <p class="claim-lede">AI named you in <em><%= appc %></em> of the <%= ansc %> answers we checked.</p>
<% } else if (ansc) { %>
  <p class="claim-lede">None of the <%= ansc %> answers we checked named you.</p>
<% } else if (hasRun && v.visibilityScore > 0) { %>
  <p class="claim-lede">You score <em><%= v.visibilityScore %></em> out of 100 across the connected engines.</p>
<% } else if (hasRun) { %>
  <p class="claim-lede">The last run found you in no answer at all.</p>
<% } else if (_total) { %>
  <p class="claim-lede">No run falls inside this date range.</p>
<% } else { %>
  <p class="claim-lede">No AI Visibility run yet.</p>
<% } %>
<p class="claim-sub"><%
  if (hasRun) { %>From the run on <%= snap && snap.date ? h.date(snap.date) : 'the latest date in this range' %>.<%
  } else if (_total) { %>No run in this period. <a class="more" href="?range=12m">Show the last 12 months</a>.<%
  } else { %>Your figures appear here after the first run.<%
  } %></p>

<%

  var _shelf = [], _off = [];

  function _cell(l, val, xt, hlp) { _shelf.push({ l: l, v: val, x: xt || '', h: hlp || '' }); }
  function _blank(n, cta, href) { _off.push({ n: n, cta: cta, href: href || '' }); }

  if (plats.length) {
    var _mentions = plats.reduce(function (t, p) { return t + (p.mentions || 0); }, 0);
    var _cites    = plats.reduce(function (t, p) { return t + (p.citations || 0); }, 0);
    _cell('Engines asked', plats.length, '');
    if (ansc != null) _cell('Answers checked', ansc, '',
      'One answer is one tracked question asked on one engine.');
    _cell('Mentions', _mentions, '');
    _cell('Citations', _cites, '',
      'Links to your own pages that the engines cited in answers that named you.');
  }

  if (!hasRun && _total) _blank('This period', 'No run recorded inside this date range', '?range=12m');
  else if (!hasRun) _blank('AI Visibility run', 'No engine has been asked about you yet');
  else if (!plats.length) _blank('Per-engine breakdown', 'This run recorded no per-engine rows');
  else if (ansc == null) _blank('Answers checked', 'This run did not record how many answers it read');
%>

<div class="bento" style="margin-top:22px">

  <div class="vdark vd-cut b12">
    <span class="vn-fillet"></span>

    <% if (locals.showStaff) { %>

      <form class="inline-form js-async-run" method="POST" action="/api/ai/run" style="position:absolute;top:0;right:0">
        <button class="vn-cut" type="submit">Refresh now
          <svg viewBox="0 0 12 12" fill="none" width="13" height="13" aria-hidden="true"><path d="M10 6a4 4 0 11-1.2-2.85M10 1.6V4H7.6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>
        </button>
      </form>
    <% } else { %>
      <a class="vn-cut" href="/prompt-explorer">See the prompts
        <svg viewBox="0 0 12 12" fill="none" width="13" height="13" aria-hidden="true"><path d="M3 9L9 3M9 3H4.2M9 3v4.8" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>
      </a>
    <% } %>
    <div class="score-hero">
      <div>
        <div class="eyebrow">AI Visibility Score <%- h.ihelp('What this score is',
          'One score for how visible you are across your connected AI engines, built from the signals on the right. '
          + 'An engine that returns no answers is left out of the score.') %></div>

        <div class="score-num tnum"><% if(hasRun){ %><%= v.visibilityScore %><small>/100</small><% } else { %><span class="noval">—</span><% } %></div>
        <% if(v.delta){ %><div class="chip <%= v.delta>=0?'pos':'neg' %>" style="margin-top:8px"><%= v.delta>=0?'▲':'▼' %> <%= Math.abs(v.delta) %> vs last run</div><% } %>

        <% if(dead.length){ %><div class="rr-meta vn-warn" style="margin-top:8px; max-width:230px"><% if(_isStaff){ %><%= dead.map(function(p){return p.name;}).join(', ') %><% } else { %><%= dead.length %> engine<%= dead.length===1?'':'s' %><% } %> returned no answers and <%= dead.length===1?'is':'are' %> left out of this score.</div><% } %>
        <% if(quiet.length){ %><div class="rr-meta" style="margin-top:8px; max-width:230px"><%= quiet.map(function(p){return p.name;}).join(', ') %>: Google showed no AI Overview for these questions. Left out of the score.</div><% } %>
        <div class="rr-meta" style="margin-top:10px; max-width:230px"><% var _st = locals.brandStanding; if(_st && _st.rank){ %>Rank <b class="tnum">#<%= _st.rank %></b> of <%= _st.total %> brand<%= (_st.total===1)?'':'s' %> named<% if(ansc){ %> · mentioned in <b><%= appc||0 %></b>/<%= ansc %> answers<% } %>.<% } else if(appc && ansc) { %>Mentioned in <b><%= appc %></b>/<%= ansc %> answers.<% } else if(ansc) { %>Not mentioned in any of the <b><%= ansc %></b> answers checked.<% } else if (_total) { %>No run in this period. <a class="more" href="?range=12m">Show the last 12 months</a>.<% } else { %>No run yet. <% if (locals.showStaff) { %>Hit <b>Refresh now</b> to check the engines.<% } else { %>Your VOCTOS team checks the engines on a schedule.<% } %><% } %></div>
      </div>
      <%

        var bdl = [
          [h.sigName('visibility'),     'visibility',      'The share of answers that named you.'],
          [h.sigName('authority'),      'authority',       'How often your own pages were cited as a source, out of 100.'],
          [h.sigName('citationQuality'),'citationQuality', 'The same citations on a narrower 0 to 100 scale.'],
          [h.sigName('sentiment'),      'sentiment',       'The share of answers that describe you favourably.'],
          [h.sigName('entityStrength'), 'entityStrength',  'How often your brand was named across the tracked questions, out of 100.']
        ];
      %>
      <%

        var _bdCols = (function (n) {
          if (n <= 3) return n;
          return Math.min(4, Math.ceil(n / 2));
        })(bdl.length);
      %>
      <div class="breakdown" style="--bd-cols:<%= _bdCols %>">
        <% bdl.forEach(function(x){ var val = bd[x[1]]; var has = val != null; %>

          <div class="bd">
            <div class="bl"><%= x[0] %><%- h.ihelp(x[0], x[2]) %></div>
            <div class="bv tnum"><%- h.sigVal(x[1], has ? val : null) %></div>

            <% if(has){ %><div class="bm"><span style="width:<%= val %>%"></span></div><% } %>
          </div>
        <% }) %>
      </div>
    </div>
  </div>

  <% if (_shelf.length) { %>
  <%

    var _sw = { 1:'b4', 2:'b6', 3:'b4', 4:'b3', 6:'b2', 12:'b1' }[_shelf.length] || 'b2';
    var _tints = ['sc-violet', 'sc-lime', 'sc-navy', 'sc-sky', 'sc-sand', 'sc-rose'];
  %>
  <% _shelf.forEach(function (s, i) { %>
    <div class="card shelf-c <%= _sw %> <%= _tints[i % _tints.length] %>">
      <div class="cl"><%= s.l %><%- s.h ? h.ihelp(s.l, s.h) : '' %></div>
      <div class="cv tnum"><%= s.v %><%- s.x %></div>
    </div>
  <% }) %>
  <% } %>

  <% if (_off.length) { %>

  <div class="voff b12">
    <div class="voff-h"><b>Not connected yet</b></div>
    <% _off.forEach(function (o) { %>
      <div class="voff-i">
        <span class="n"><%= o.n %></span>
        <% if (o.href) { %><a href="<%= o.href %>"><%= o.cta %></a><% } else { %><span class="n"><%= o.cta %></span><% } %>
      </div>
    <% }) %>
  </div>
  <% } %>

  <div class="card b12">

    <div class="card-h"><h3>AI platforms</h3><span class="hint">Last run on <%= snap && snap.date ? new Date(snap.date).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' }) : '—' %></span></div>
    <div style="overflow-x:auto">
      <% if (!plats.length) { %>
        <div class="card-p rr-meta" style="text-align:center; padding:34px">No engine results for this period.</div>
      <% } else { %>
      <table class="tbl aip-tbl">
        <thead><tr><th>Engine</th><th>Visibility <span class="th-note">vs last run</span></th><th>Avg position</th><th>Mentions</th><th>Citations</th><th>Positive</th><th>Neutral</th><th>Negative</th></tr></thead>
        <tbody>
          <% plats.forEach(function(p){ %>
            <tr>
              <td class="strong"><span style="display:inline-flex;align-items:center;gap:8px"><%- include('../partials/engine-mark', { engine: p.name || p.code }) %><%= p.name %></span></td>
              <td>
                <% if(p.visibility==null && p.noOverview > 0){ %><span class="muted" title="Asked <%= p.asked||0 %> question<%= (p.asked===1?'':'s') %>; Google displayed no AI Overview for <%= p.noOverview %> of them, so no brand could be named.">no overview shown</span>

                <% } else if(p.visibility==null){ %><span class="muted" title="<%= (_isStaff && p.error) ? p.error : 'This engine returned no answers in the last run' %>">no answers</span>
                <% } else { %>
                  <span class="num"><%= p.visibility %>%</span>

                  <% if(p.delta!=null && p.delta!==0){ %><span class="chip <%= p.delta>0?'pos':'neg' %>" title="Against the previous run"><%= p.delta>0?'▲'+p.delta:'▼'+Math.abs(p.delta) %></span>

                  <% } else if(p.delta===0){ %><span class="chip flat" title="Measured against the previous run, and unchanged"><span class="flatbar" role="img" aria-label="unchanged"></span></span><% } %>
                <% } %>
              </td>
              <td class="num"><%= p.avgPosition!=null ? p.avgPosition : '—' %></td>
              <td class="num"><%= h.int(p.mentions) %></td><td class="num"><%= h.int(p.citations) %></td>
              <td style="color:var(--pos)"><%= p.pos!=null ? p.pos+'%' : '—' %></td>
              <td class="muted"><%= p.neu!=null ? p.neu+'%' : '—' %></td>
              <td style="color:var(--neg)"><%= p.neg!=null ? p.neg+'%' : '—' %></td>
            </tr>
          <% }) %>
        </tbody>
      </table>
      <% } %>
    </div>
  </div>

  <%
    var S = (typeof series !== 'undefined' && series) ? series : { points: [], engines: [] };

    var runs = (S.points || []).filter(function(p){ return !p.future; }).length;
    var anyGap = S.engines.some(function(e){ return e.gaps > 0; });
    var total = (typeof totalRuns !== 'undefined') ? totalRuns : runs;
  %>

  <div class="card b12">
    <div class="card-h">
      <h3>Visibility history</h3>
      <span class="hint">

        <% var _n = (S.runs != null ? S.runs : runs); %>

        <% if(_n){ %><%
          if (S.grouped === 'quarter') { %>one point per quarter, <%= _n %> run<%= _n===1?'':'s' %> in this period<%
          } else { %><%= _n %> run<%= _n===1?'':'s' %> in this period<%
          }
          if (locals.droppedRuns) { %> · <span style="opacity:.75"><%= droppedRuns %> early test run<%= droppedRuns === 1 ? '' : 's' %> not shown</span><% }
          if(S.projected){ %> · <span style="opacity:.75">dashed line: what each engine could reach</span><% } %><%
        } else { %>per engine<% } %>
      </span>
    </div>

    <% var _years = (typeof years !== 'undefined' && years) ? years : []; %>

    <% if (_years.length) { %>

      <div class="rangebar">
        <span class="rr-meta">Jump to</span>
        <div class="presets">
          <% _years.forEach(function(y){
               var from = y.year + '-01-01', to = y.year + '-12-31';
               var on = range.from === from && range.to === to; %>
            <a class="rp <%= on ? 'on' : '' %>"
               href="?range=custom&from=<%= from %>&to=<%= to %>"
               title="<%= y.runs %> run<%= y.runs===1?'':'s' %> recorded in <%= y.year %>"><%= y.year %></a>
          <% }) %>
          <a class="rp <%= range.preset === '12m' ? 'on' : '' %>" href="?range=12m">Last 12 months</a>
        </div>
      </div>
    <% } %>
    <div class="card-p" style="padding-top:12px">
      <% if (!S.engines.length) { %>
        <div class="rr-meta" style="text-align:center; padding:34px">
          <% if(runs){ %>
            No per-engine results in these runs.
          <% } else if(total) { %>
            No run in this period.
            <% if(typeof nearestRun!=='undefined' && nearestRun){ %>The most recent one was <b style="color:var(--ink)"><%= h.date(nearestRun) %></b>. <a class="more" href="?range=12m">Show the last 12 months</a>.<% } %>
          <% } else { %>
            No runs yet. Each AI Visibility run adds a point per engine<% if (locals.showStaff) { %>, so hit <b>Refresh now</b><% } %>.
          <% } %>
        </div>
      <% } else { %>

      <div class="legend" data-linechart>
        <% S.engines.forEach(function(e){ %>
          <span class="lgi on" data-line="<%= e.code || e.name %>" role="button" tabindex="0"
                title="Click to hide <%= e.name %>">
            <i class="lg" style="border-color:<%= e.color %>"></i><%- include('../partials/engine-mark', { engine: e.name || e.code, size: 'sm', bare: true }) %><%= e.name %>
            <% if(e.last!=null){ %><b style="color:var(--ink)"><%= e.last %>%</b><% } %>

            <% if(e.delta!=null && e.delta!==0){ %><span class="mini <%= e.delta>0?'pos':'neg' %>" title="From this engine's first reading in this window to its most recent, not against the previous run."><%= e.delta>0?'▲':'▼' %><%= Math.abs(e.delta) %> <span class="lg-since">over <%= e.measured %> reading<%= e.measured === 1 ? '' : 's' %></span></span><% } %>
          </span>
        <% }) %>
      </div>

      <%

        var _pdfPts = (S.points || []).map(function (p, i) {
          if (p.future) return null;
          return {
            label: p.label,
            rows: (S.engines || []).map(function (e) {
              var v = (e.values || [])[i];
              return { k: e.name, v: v == null ? '' : v + '%' };
            })
          };
        }).filter(Boolean);
      %>
      <svg class="chart" viewBox="0 0 690 200"
           data-xs="<%= JSON.stringify(S.xs || []) %>"

           <% if (_pdfPts.length >= 2) { %>data-points="<%= JSON.stringify(_pdfPts) %>"<% } %>
           data-labels="<%= JSON.stringify((S.points||[]).map(function(p){ return p.full || p.label; })) %>"
           data-future="<%= JSON.stringify((S.points||[]).map(function(p){ return !!p.future; })) %>">

        <line class="ax" x1="28" y1="30" x2="28" y2="180"/>
        <line class="ax" x1="28" y1="180" x2="678" y2="180"/>
        <line x1="28" y1="30"  x2="678" y2="30"  stroke="var(--line-2)"/>
        <line x1="28" y1="105" x2="678" y2="105" stroke="var(--line-2)"/>
        <line x1="28" y1="180" x2="678" y2="180" stroke="var(--line-2)"/>
        <text x="22" y="34"  text-anchor="end" fill="var(--muted-2)" font-size="9">100</text>
        <text x="22" y="109" text-anchor="end" fill="var(--muted-2)" font-size="9">50</text>
        <text x="22" y="184" text-anchor="end" fill="var(--muted-2)" font-size="9">0</text>

        <% if(S.dividerX && S.projected){ %>
          <rect data-forecast x="<%= S.dividerX %>" y="26" width="<%= Math.max(0, 690 - S.dividerX) %>" height="158"
                fill="var(--muted-2)" opacity="0.05"/>
        <% } %>
        <% S.engines.forEach(function(e){ var p = e.line || { d: '', dots: [] }; var f = e.forecast; %>
          <g data-series="<%= e.code || e.name %>"
             data-name="<%= e.name %>" data-color="<%= e.color %>"
             data-values="<%= JSON.stringify(e.values || []) %>"
             data-expected="<%= JSON.stringify((e.forecast && e.forecast.expected) || []) %>">
            <% if(f){ %>
              <g data-forecast>

                <% if(f.line && f.line.d){ %><path d="<%= f.line.d %>" fill="none" stroke="<%= e.color %>"
                   stroke-width="1.8" stroke-dasharray="5 4"
                   opacity="0.8" stroke-linecap="round"/><% } %>
              </g>
            <% } %>
            <% if(p.d){ %><path d="<%= p.d %>" fill="none" stroke="<%= e.color %>" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/><% } %>
            <% p.dots.forEach(function(dt){ %><circle cx="<%= dt.x %>" cy="<%= dt.y %>" r="3" fill="<%= e.color %>"/><% }) %>
          </g>
        <% }) %>
        <% if(S.dividerX && S.projected){ %>
          <g data-forecast>
            <line x1="<%= S.dividerX %>" y1="26" x2="<%= S.dividerX %>" y2="184" stroke="var(--muted-2)" stroke-width="1" stroke-dasharray="3 3" opacity=".7"/>
            <text x="<%= S.dividerX - 4 %>" y="24" text-anchor="end" fill="var(--muted-2)" font-size="8.5">live</text>
            <text x="<%= S.dividerX + 4 %>" y="24" fill="var(--muted-2)" font-size="8.5">expectations</text>
          </g>
        <% } %>
      </svg>

      <div class="axis-x" style="padding-left:34px"><% var _seen = null; S.points.forEach(function(pt){
           var dup = pt.label === _seen; _seen = pt.label; %><% var _cls = (pt.future ? 'fut ' : '') + (dup ? 'rep' : ''); %><span<%- _cls.trim() ? ' class="' + _cls.trim() + '"' : '' %> title="<%= pt.full || pt.label %>"><%= dup ? '·' : pt.label %></span><% }) %></div>

      <% var _hasVerdict = S.engines.some(function(e){ return e.last != null; }); %>
      <% if (_hasVerdict) { %>
        <div class="fc-box">
          <div class="fc-h">

            <b>What's reachable</b>
            <span class="rr-meta">how far each engine could get<% var _any = (S.engines.find(function(e){return e.forecast;}) || {}).forecast; if (_any) { %> by <%= _any.endLabel %><% } %>, with the work behind it</span>
            <button class="btn btn-sm" type="button" data-forecast-toggle style="margin-left:auto">Hide expectations</button>
          </div>

          <div class="fc-rows">
            <% S.engines.forEach(function(e){
                 var f = e.forecast, u = e.unreadable;

                 if (e.last == null) return;
                 var cap = f ? f.ceiling : 100;
                 var pctNow = Math.max(0, Math.min(100, Math.round(((e.last || 0) / cap) * 100)));
                 var pctGain = f ? Math.max(0, Math.min(100 - pctNow, Math.round((f.gain / cap) * 100))) : 0;
            %>
              <div class="fc-row" style="display:block; padding:10px 0">
                <div class="row-between" style="font-size:var(--fs-sm); align-items:center; gap:8px">
                  <span class="fc-n" style="display:inline-flex; align-items:center; gap:6px">
                    <%- include('../partials/engine-mark', { engine: e.name || e.code, size: 'sm', bare: true }) %><%= e.name %>

                    <% if((f && f.declining) || (u && u.declining)){ %>
                      <span class="chip neg" title="The measured readings are falling. The opportunity is real, but the trend is against it right now">falling now</span>
                    <% } %>
                  </span>
                  <span class="num">
                    <% if (f) { %>
                      <%= e.last %>%<span class="rr-meta"> today</span>
                      <% if (f.gain > 0) { %>
                        <span class="mini pos" style="margin-left:6px">▲<%= f.gain %></span>
                        <b style="color:var(--ink); margin-left:6px"><%= f.mostLikely %>%</b>
                      <% } else { %>
                        <span class="rr-meta" style="margin-left:6px">at its ceiling</span>
                      <% } %>
                    <% } else { %>
                      <%= e.last %>%<span class="rr-meta"> today</span>
                    <% } %>
                  </span>
                </div>

                <% if (f) { %>
                  <div class="meter" style="margin-top:8px; display:flex">
                    <span style="width:<%= pctNow %>%; background:<%= e.color %>; border-radius:0"></span>
                    <span style="width:<%= pctGain %>%; background:<%= e.color %>; opacity:.28; border-radius:0"></span>
                  </div>
                  <div class="rr-meta" style="margin-top:5px; font-size:var(--fs-2xs)">
                    could reach <b style="color:var(--ink)"><%= f.mostLikely %>%</b>
                    (<%= f.low %>–<%= f.high %>%) by <%= f.endLabel %> · from <%= f.basedOn %> reading<%= f.basedOn===1?'':'s' %>
                  </div>
                <% } else { %>

                  <div class="rr-meta" style="margin-top:6px">
                    <% if (u && u.atCeiling) { %>
                      <span class="chip pos">at the top of its range</span>
                      This engine already names you in <b style="color:var(--ink)"><%= u.current %>%</b> of answers,
                      the highest we have measured for it. The goal here is to hold it.
                    <% } else if (u && u.reason === 'swings') { %>
                      <span class="chip warn">too changeable to estimate</span>
                      This engine's answer moves by <b style="color:var(--ink)"><%= u.avgJump %></b> points
                      between runs on average, too much to draw a reliable trend.
                    <% } else if (u) { %>
                      <span class="chip warn">too scattered to estimate</span>
                      The readings swing by <b style="color:var(--ink)"><%= u.spread %></b> points across
                      <%= u.basedOn %> runs, too wide for a useful estimate.
                    <% } else { %>
                      <span class="chip flat">not enough runs yet</span>
                      <%= e.measured %> reading<%= e.measured === 1 ? '' : 's' %> so far. An estimate needs
                      <b style="color:var(--ink)"><%= S.minPoints %></b>.
                    <% } %>
                  </div>
                <% } %>
              </div>
            <% }) %>
          </div>

          <%
            var _fc = (S.engines.find(function(e){ return e.forecast; }) || {}).forecast || {};
            var _fromLeader = _fc.ceilingFrom === 'leader';
          %>
          <div class="rr-meta" style="margin-top:10px">
            What each engine could reach by <%= _fc.endLabel %> with the planned content, citation and authority work.

            <span class="ihelp-w" tabindex="0" role="button" aria-label="How this is worked out">
              <svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6.4" stroke="currentColor" stroke-width="1.4"/><path d="M8 7.1v4M8 4.9v.1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg> how this is worked out
              <span class="ihelp-pop" role="tooltip"><b>How this is worked out</b>

                <b>The ceiling is <%= _fc.ceiling %>%</b><% if (_fromLeader) { %>,
                the share the best-performing brand holds today<% } else { %>, a little above the best level this engine has held<% } %>.
                <br><br>
                <b>The gain</b> depends on the direction of the readings and how many there are (<%= _fc.basedOn %> so far).
                The pale part of each bar and the shaded area on the chart show it.
                <br><br>
                Engines whose readings swing too widely get no estimate.
              </span>
            </span>
          </div>
        </div>
      <% } else if (runs >= 2 && S.canProject) { %>
        <div class="rr-meta" style="margin-top:10px">
          <span class="ihelp-w" tabindex="0" role="button" aria-label="Why there are no expectations yet">
            <svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6.4" stroke="currentColor" stroke-width="1.4"/><path d="M8 7.1v4M8 4.9v.1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg> Why there are no expectations yet
            <span class="ihelp-pop" role="tooltip"><b>Why there are no expectations yet</b>Estimates appear after <b><%= S.minPoints %> runs</b> per engine.</span>
          </span>
        </div>
      <% } %>

      <% if (runs === 1) { %>
        <div class="rr-meta" style="margin-top:10px">
          One run in this period (<%= S.points[0].label %>), so each engine shows as a single dot.
          <% if (total > 1) { %>
            There <%= total===2?'is':'are' %> <%= total %> run<%= total===1?'':'s' %> in total.
            <a class="more" href="?range=12m">Show the last 12 months</a>.
          <% } else { %>
            The next run adds the second point.
          <% } %>
        </div>
      <% } %>
      <% if (anyGap) { %>

        <div class="rr-meta" style="margin-top:10px">
          <span class="ihelp-w" tabindex="0" role="button" aria-label="Breaks in a line"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6.4" stroke="currentColor" stroke-width="1.4"/><path d="M8 7.1v4M8 4.9v.1" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg> Breaks in a line
            <span class="ihelp-pop" role="tooltip"><b>Breaks in a line</b>
              A break in a line is a run where that engine returned no answers<% if (_isStaff) { %> (a quota
              limit or an outage on the day)<% } %>. That run is left blank.
            </span>
          </span>
        </div>
      <% } %>
      <% } %>
    </div>
  </div>
</div>
