{{define "diagnostics"}}
<div class="card">
  <div class="section-title">
    <div>
      <h2>日志审计</h2>
      <div class="muted small">按设备查看日志与运行指标，并进入审计记录和高级调试。</div>
    </div>
    <a class="btn ghost" href="/ui/api">高级调试</a>
  </div>
</div>

<div class="card">
  <h2>日志分析</h2>
  <div class="table-wrap" style="margin-top:10px">
    <table>
      <thead>
        <tr><th>节点</th><th>状态</th><th>管理地址</th><th>诊断入口</th></tr>
      </thead>
      <tbody>
        {{range .Devices}}
        <tr>
          <td>
            <a class="mono" href="/ui/devices/{{.DeviceID}}">{{if .DeviceName}}{{.DeviceName}}{{else}}{{.DeviceID}}{{end}}</a>
            <div class="muted small mono">{{.DeviceID}}</div>
          </td>
          <td>{{if .Online}}<span class="pill ok">在线</span>{{else}}<span class="pill bad">离线</span>{{end}}</td>
          <td class="mono">{{.IP}}:{{.AgentPort}}</td>
          <td>
            <div class="actions">
              <a class="btn ghost" href="/ui/devices/{{.DeviceID}}/logs?limit=200">诊断日志</a>
              <a class="btn ghost" href="/ui/devices/{{.DeviceID}}/graphs">运行指标</a>
            </div>
          </td>
        </tr>
        {{else}}
        <tr><td colspan="4" class="muted">暂无设备。请先在“新增设备”页扫描或手动添加。</td></tr>
        {{end}}
      </tbody>
    </table>
  </div>
</div>

<div class="card">
  <div class="section-title">
    <div>
      <h2>审计记录</h2>
    </div>
    <a class="btn ghost" href="/ui/audit">进入审计记录</a>
  </div>
  <div class="muted small">查看任务执行、设备操作和配置下发相关的审计记录。</div>
</div>
{{end}}
